www.webdeveloper.com
Results 1 to 4 of 4

Thread: No postback after savefile dialog

  1. #1
    Join Date
    Oct 2004
    Location
    Melbourne, AU
    Posts
    13

    No postback after savefile dialog

    I finally got my page so you can save a file from the server to the local machine, however, once it is saved the page doesn't refresh itself or continue doing what it should, it just sits there!
    The download function is sent the address of the file to download and the name to call it as variables.
    Download function code:

    Sub test(ByVal strFilename, ByVal strDownloadFilename)
    Dim objStream, fso, objFilestream
    Dim intFileLength

    ' clear the buffer
    Response.Buffer = True
    Response.Clear()

    ' create stream
    objStream = Server.CreateObject("ADODB.Stream")
    objStream.Open()

    ' set as binary
    objStream.Type = 1

    ' check the file exists
    fso = Server.CreateObject("Scripting.FileSystemObject")
    If Not fso.FileExists(strFilename) Then
    tbFilter1.txt = "File not found"
    End If

    ' get length of file
    objFilestream = fso.GetFile(strFilename)
    intFileLength = objFilestream.size

    objStream.LoadFromFile(strFilename)

    'format strFileName
    If Len(Trim(strDownloadFilename)) > 0 Then
    strDownloadFilename = Trim(strDownloadFilename)
    Else
    strDownloadFilename = objFilestream.name
    End If

    ' send the headers to the users browser
    Response.AddHeader("Content-Disposition", "attachment; filename=" & strDownloadFilename)
    Response.AddHeader("Content-Length", intFileLength)
    Response.Charset = "UTF-8"

    ' output the file to the browser
    Response.BinaryWrite(objStream.Read)
    Response.Flush()

    ' tidy up
    objStream.Close()
    objStream = Nothing

    'objFilestream.Close()
    objFilestream = Nothing
    fso = Nothing

    tbFilter1.Text = "Done!"

    End Sub

    I can step through past the end, but it doesn't DO anything! The text "Done!" never appears, and there is no postback. If I click something else, I get writing appearing in the background f the website.

    Why oh why?!?

  2. #2
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Classic ASP does not have that type of functionality. What is 'tbFilter1'? You cannot set the text value of a textbox (or other HTMl control) from the server via a .Text property.

    You must use Response.Write() to print text to the output from within an ASP environment.

    Alternatively, you could use Response.Redirect() to redirect the user to another page after the function is completed.

    Regards.

  3. #3
    Join Date
    Oct 2004
    Location
    Melbourne, AU
    Posts
    13
    Well it is ASP.NET, but I figured here was probably a better place for it than the generic .NET section.

    The textbox is an ASP:TEXTBOX.

    This is all done in the codebehind, not in the HTML part.

  4. #4
    Join Date
    Jan 2004
    Location
    Melbourne, Australia
    Posts
    5,298
    Ok, this forum only deals with classic ASP. I will move this thread for you.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles