Postback after a Response.Writefile()

G

Guest

i have a treeview on a webform (.aspx). when the user selects an appropriate node on the tvw. and clicks on a link button, i'm downloading a corresponding file to the client (from the server). so far so good. all of that works.
after the download, i want to refresh the treeview and redisplay the current node with a different color. and also repopulate a property page on the right of the treeview

but my problem is that during the file download process, after a response.writefile() and a response.end() statement, the thread execution stops. even if the treeview refresh/navigate code executes first..lets say before the file download call, it does not show the changes visually on the page. like there was no postback.

***sample code**
private sub tvwMain_SelectedIndexChanged(sender, e) handles bla..
dim sFileName = tvwMain.GetNodeFromIndex(e.NewNode).ID
call RefreshTreeView 'reloads the tree and navigates back to the current nod

response.clear(
response.contenttype = ..
response.appendheader(...
response.writefile(sfilename
'response.flush()
response.end(
end su

i worked around this issue by using a javascript popup() window and having a download button in the popup.aspx, but i still couldnt close the popup automatically after a file download, using a window.close() or self.close() javascript, because the close() code wont execute correctly after a response.writefile

any suggestions on how it's done in the real "ASP.NET" world

thank
Carte
 
R

Rick Strahl [MVP]

I don't think there's a way to do this with plain code.

Possibly by using an IFrame and having the parent window monitor hte IFrame
and its download events/state, but that is really messy if it even would
work.

Is it really that important that the UI is updated? I mean standard protocol
for Web downlaods is to pop up a dialog and download asynchronously...
trying to emulate a Windows model in the browser doesn't always work <g>...

+++ Rick ---

--

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web


Carter said:
i have a treeview on a webform (.aspx). when the user selects an
appropriate node on the tvw. and clicks on a link button, i'm downloading a
corresponding file to the client (from the server). so far so good. all of
that works.
after the download, i want to refresh the treeview and redisplay the
current node with a different color. and also repopulate a property page on
the right of the treeview.
but my problem is that during the file download process, after a
response.writefile() and a response.end() statement, the thread execution
stops. even if the treeview refresh/navigate code executes first..lets say
before the file download call, it does not show the changes visually on the
page. like there was no postback.
***sample code***
private sub tvwMain_SelectedIndexChanged(sender, e) handles bla...
dim sFileName = tvwMain.GetNodeFromIndex(e.NewNode).ID
call RefreshTreeView 'reloads the tree and navigates back to the current node

response.clear()
response.contenttype = ...
response.appendheader(...)
response.writefile(sfilename)
'response.flush()
response.end()
end sub

i worked around this issue by using a javascript popup() window and having
a download button in the popup.aspx, but i still couldnt close the popup
automatically after a file download, using a window.close() or self.close()
javascript, because the close() code wont execute correctly after a
response.writefile.
 
G

Guest

yeah, it is important to refresh the tree after a filedownload.
and here's the reason why: a node in the tree view (and it's corresponding property page) represents a node from an object oriented CMS node(using COM interop). so...users select a node and check it out. i have code behind form to check the object out and saves it as an xml file on the server. (which is then downloaded to the client browser) i need to update the current node (and the content) to display visually that it's now checked out (or checkin,undo checkout etc

using a popup to download the file works, and it refreshes the main page (treeview) fine. if only i could close the popup page after the response.writefile(), that'd be great. i tried using a timer to kick off a download and it didnt work.
 
Joined
Oct 9, 2009
Messages
1
Reaction score
0
Possible

I am running into the same problem, only I don't have the option of a popup as I am running a web part. Have you found a way around this? If you are using a popup page, have you thought of putting the response code in the unload event handler and then just executing an unload when the popup inits?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top