...

View Full Version : Using Response.Write [ASP.net]



Shaitan00
02-01-2005, 08:22 AM
I am trying to post information to screen, in ASP.net I was told (and see everywhere) to use Response.Write. 1) I have been looking around but not 100% what Response.Write is supposed to do (messagebox?)

Currently I am using the following code:
HTML SOURCE CODE:
<body bgColor="#ffffff">
<form id="Form1" style="TEXT-ALIGN: center" method="post" encType="multipart/form-data" runat="server">
<INPUT id="fileUpdate" type="file" name="fileUpdate" runat="server"><br>
<INPUT id="subUpdate" onclick="subUpdate_ServerClick" type="submit" value="Upload" name="subUpdate" runat="server"><br>
</form>
</body>

ASPX.CS CODE:
private void subUpdate_ServerClick(object sender, System.EventArgs e)
{
string appDir = ConfigurationSettings.AppSettings["ApplicationDir"];
string updDir = ConfigurationSettings.AppSettings["UpdateDir"];

string SaveLocation = appDir + updDir + fn;

try
{
Response.Write(SaveLocation);
Response.Write("The file has been uploaded.");
}
catch ( Exception ex )
{
Response.Write("Error: " + ex.Message);
}
}

As you can see I am just trying to output the string SaveLocation (cannot debug ASP). I run the code with no errors but nothing occurs, seems like th Response.Write does not do anything. Can someone please help explain to me what I am doing wrong? Am I forgetting something or not using the
Response.Write correctly? Is there something else I should be using?

gwendaal
02-01-2005, 12:20 PM
try
{
System.Web.HttpContext.Current.Response.Write(SaveLocation);
System.Web.HttpContext.Current.Response.Write("The file has been uploaded.");
}
catch ( Exception ex )
{
Throw new Exception("Error: " + ex.Message);
}
}

ghell
02-01-2005, 03:22 PM
im not really sure about this as i pretty much only use classic asp but

enctype="multipart/form-data" <-- doesnt that mean that it has to be read as binary?

Shaitan00
02-01-2005, 06:18 PM
ghell: No clue, I was told it was needed for the INPUT=file used to browse for the files to upload. It is in every samples/example I have ever seen...

ghell
02-02-2005, 09:42 AM
yea, as i have said i only use classic asp but in that you need a binaryread to get the information (that is why a lot of people use upload components binary is confusing :confused: )

seems to be a lot of people all of a sudden asking for asp upload components, i posted a pure asp one the other day in here so maby if you can look at the classes in that you can see how it works and change it to asp.net *shrugs*



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum