How to upload an image - file-upload

HI, I am using asp as server side script. I am calling asp page from java by HttpURLConnection and passing the image by ImageIO.write() method. can any body tell me how can I upload that file from asp into my server directory.

For a pure (no DLL) upload, you should look at a Pure ASP Upload or check out this article
But, a more common, tested, with better performance solution is installing a third party library.
I like AbcUpload from WebSuperGoo (free with LinkBack license)
basicupload.htm
<html>
<body>
<form method="post" action="basicupload.asp" enctype="multipart/form-data">
<input type="file" name="filefield"><br>
<input type="submit" name="submit" value="submit">
</form>
<body>
</html>
basicupload.asp
<% #Language="VBScript" %>
<%
Set theForm = Server.CreateObject("ABCUpload4.XForm")
theForm.Overwrite = True
If theForm.Files("filefield").FileExists Then
theForm.Files("filefield").Save "myupload.dat"
End If
%>
<html>
<body>
File uploaded...
</body>
</html>

Related

arabic text get reversed in <pre> tag in ASP.NET Core MVC app

I am having real problem with Arabic text in <pre> tag
For example if I put this code in a page view
<pre>
<html>
<head>
<title>First HTML Page</title>
</head>
<body>
<h1><span>اول صفحة ويب</span></h1>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</body>
</html>
</pre>
I get this display in browser
Here you can see that the arabic text is reversed
This happens just in ASP.NET Core MVC. In other frameworks, the text is displayed correctly.
I've tried to change the dir and the lang attributes but it does not help.
I copied your code snippet and reproduced the issue in my side, I noticed that the content in the page is wrong but in F12 is right, so I'm afraid the browser deal with specific language content automatically for the elements in <pre> tag... So I tried to change the direction manually with the style. How do you think about it?
<div>
<div>
<div style="direction:ltr;unicode-bidi: bidi-override;color:red">اول صفحة ويب</div>
<span>اول صفحة ويب</span>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</div>
<pre >
<html>
<head>
<title>First HTML Page</title>
</head>
<body>
<h1><span style="direction:rtl;unicode-bidi: bidi-override;">اول صفحة ويب</span></h1>
<h1><span>اول صفحة ويب</span></h1>
<p>هذه أول فقرة ننشؤها في أول صفحة</p>
</body>
</html>
</pre>
</div>

How do you set focus on a particular webpage element? VB.net

Say for example this is my html document.
<html>
<head>
</head>
<body>
<div id="1">
</div>
<div id="2">
</div>
<div id="3">
</div>
</body>
</html>
How in VB.net would would i set the webrowser control to scroll automatically or focus on a specific element?
Thanks
HTML ID and Class names can't begin with a digit, so id="1" is invalid.
What happens with the page after it is rendered is the web browser's business. VB.Net is server side code, so you're better off using JavaScript.
<body onLoad='document.getElementById("myDiv1").focus();'>
After reading a little more closely, I see you specified scrolling in a WebBrowser control. Have a look at this answer.

Opening web page on default Web browser and hiding URL parameters

I have an application that needs to open an external URL on the default Web Browser but I don't want to show the parameters on the URL so I think I need to make a POST instead of a GET, but how?
I'm using the following code to open an external default browser
Friend Sub WebOpen(ByVal WebAddress As String)
Dim sInfo As New ProcessStartInfo(WebAddress)
Process.Start(sInfo)
End Sub
But this expose all the parameters on the URL bar since make a GET not a POST.
Solution:
Make a temporary HTML file and open it using the previous code (WebOpen(ByVal WebAddress As String))
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<!-- <head>
</head> -->
<body>
<form name="Login" method="post" action="http://www.yourWebPage.com/" target="_self">
<input id="accountLoginField" class="textInput" name="account" value="accountX" size="24"
maxlength="32" type="hidden"/>
<input id="userLoginField" class="textInput" name="user" value="userX" size="24"
maxlength="32" type="hidden"/>
<input class="textInput" name="password" value="PassX" size="24" maxlength="32" type="hidden"/>
<input name="submit" value="Start Session" type="submit" id="btn" style="color: transparent;
background-color: transparent; border-color: transparent; cursor: default;"/>
<script type="text/javascript">
<!--
var counter = 0;
var maxCount = 50;
function pushSubmit() {
if (counter++ < maxCount) {
document.getElementById('btn').click();
}
}
//start the process
window.setTimeout(pushSubmit(), 30);
</script>
</form>
</body>
</html>
Hopefully you were able to find your answer using an older post from here: How to open IE with post info in C#?
Please mark this as an answer if this helped you solved your issue.
You could use a string encryptor in vb.net (you'll have to find that yourself) and then do this:
Process.Start(Decrypt("encryptedstringhere"))
That will 'hide' the parameters from anyone trying to decompile your code.
OR
Once you have compiled your executable, find a vb.net obfuscation program (just google it) and obfuscate your exe. This will make it unreadable to nayone who attempts to decompile it or find what string is in your parameters....
Hope this helped!
Rodit

My Implementation of SimpleModal isn't working

I'm a total jQuery noob and I'm trying to use Eric Martin's SimpleModal Confirm Override dialog box in an ASP.Net web page. It's not working - no surprise, I have no idea what I'm doing! Here's a simplified version of my aspx page:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Reimbursements.aspx.cs" Inherits="EAS.telecom.Reimbursements" MasterPageFile="~/common/default.master" Title="Reimbursements" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<%# MasterType VirtualPath="~/common/default.master" %>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="Main">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type='text/javascript' src='~/jquery/confirm/js/jquery.js'></script>
<script type='text/javascript' src='~/jquery/confirm/js/jquery.simplemodal.js'>
$.modal('#confirm');</script>
<script type='text/javascript' src='~/jquery/confirm/js/confirm.js'></script>
<script language="javascript" type="text/javascript">
//some regular javascript here
</script>
<asp:Panel runat="server" ID="pnlEmployeeInfo" Enabled="false">
<div id='content'>
<div id='confirm-dialog'>
<h3>Confirm Override</h3>
<p>A modal dialog override of the JavaScript confirm function. Demonstrates the use of the <code>onShow</code> callback as well as how to display a modal dialog confirmation instead of the default JavaScript confirm dialog.</p>
<input type='button' name='confirm' class='confirm' value='Demo'/> or <a href='#' class='confirm'>Demo</a>
</div>
<!-- modal content -->
<div id='confirm'>
<div class='header'><span>Confirm</span></div>
<div class='message'></div>
<div class='buttons'>
<div class='no simplemodal-close'>No</div><div class='yes'>Yes</div>
</div>
</div>
<!-- preload the images -->
<div style='display:none'>
<img src='~/jquery/confirm/img/confirm/header.gif' alt='' />
<img src='~/jquery/confirm/img/confirm/button.gif' alt='' />
</div>
</div>
//more controls, including an AJAX TabContainer
</asp:Panel></asp:Content>
When I run the page, I see the Demo button and the Demo link, but clicking on them does nothing. What am I missing? Can I use SimpleModal on an ASP.Net page? Within a Content control? Thanks much!
Multiple issues here.
A script tag with a src cannot also contain script body. So, this is invalid.
<script src='~/jquery/confirm/js/jquery.simplemodal.js'>$.modal('#confirm');</script>
If you use an ID, SimpleModal is called like so: $('#content').modal();
That call needs to be within a click event handler.
<script>
$(document).ready(function () {
$('a.confirm').click(function () {
$('#content').modal();
});
});
</script>

Use controller result from other mvc project within solution

I've got a new solution that contains several project 'groups'. Each group contains a Cloud Project, a Web Role Project and a Test Project. All Web Role Projects are MVC4.
One of the Web Roles is the entry point for the visitor. Parts of what the visitor will see, should come from the other Web Roles from within the solution. I cannot get it working and after spending several hours googling, I still cannot solve it. Maybe anyone can be helpful on this issue.
For example, I need to fill the header content with data that I can get from one of the other Web Roles. Let's call that controller HeaderController. The controller in the main project (HomeController) looks like this:
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
//var headerController = new Generic.HeaderFooterContainer.Controllers.HeaderController();
//var foo = headerController.Index().ExecuteResult();
//ViewBag.Header = headerController.;
return View();
}
In the comments are some things I've tried to debug some things.
Here's the page layout of the main project. The body is still empty, as this problem is just about the page header which could be placed as html from the ViewBag or ViewData or even with an own #section.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta charset="utf-8" />
<title>#ViewBag.Title</title>
<link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="viewport" content="width=device-width" />
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="headerHolder">
<div class="innertube">
<div id="header">
#ViewBag.Header
</div>
</div>
</div>
<div class="contentHolder">
<div class="innertube">
<div id="content">
#RenderBody()
</div>
</div>
</div>
<div class="footerHolder">
<div class="innertube">
<div id="footer">
</div>
</div>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bms")
#RenderSection("scripts", required: false)
</body>
</html>
The problem I face is that I just can't find out how I should make this work. How do I get the data in the header? A few things I've noticed are:
If I run the HeaderFooterContainer project in its dedicated solution, it works alright (I can get /Header and get the expected response displayed in the browser window)
If I run the Main project, I can see the home page, but if I ask for /Header, it can find the controller, but not the view. It's probably looking for the view in the main project although it is located in the HeaderFooterContainer project.