Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post

    Question Using Response.Write [ASP.net]

    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?

  • #2
    Regular Coder
    Join Date
    Jul 2004
    Location
    France
    Posts
    141
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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);
    }
    }

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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?

  • #4
    New Coder
    Join Date
    Jan 2005
    Posts
    74
    Thanks
    0
    Thanked 1 Time in 1 Post
    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...

  • #5
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    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 )

    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*


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •