Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

Posted
Response.write will write to your browser. It is up to you to have browser conforming html. depending on where you do a response.write, in which page event, what you write will be in different places. Typically if you do it in your page_load, it will be written before any html you have in your aspx page, so view the source of your page in the browser, it just might be in there.
Posted

Don't you have to use a tag defining the response.write as a JavaScript message?

 

If you are using ASP.NET just use a label and assign the text property during the page loade event.

Posted

Then I guess something else is really wrong with my code (see it? code is all there). I have tried adding a label before (lblsave) and added the line:

lblsave.text = SaveLocation;

or even

lblsave.text = "Hello";

 

right after I define the SaveLocation string (in the C# Code) and it doesn't work. nothing appears when I run the Web App so I assume this _ServerClick event is never called? Am I using the correct event?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...