Hello,
In Asp.Net,I am using a response.write technique to download a file on aGridView_RowCommand event. The Response.End() or something else is causing the UpdatePanel.Update() call to not perform>
Here is a summary and code parts of what I am doing.
I have a label Label1 and a textbox TextBox1 on my page as well as GridView1.
Both Lablel1 and TextBox1 are in an Update Panel.
I have a button with a command event that will update the text for Label1 and Textbox1 when the button is clicked.
Sub Button1_Command(sender As Object, e As CommandEventArgs) Handles Button1.Command
TextBox1.Text = e.commandargument
Label1.Text = e.commandname
Updatepanel1.Update()
sub end
This all works so I have my Updatepanel and other code working as expected.
Now, I next want to download a file after the user selects which file in a GridView
Here is how that is setup and is working:
Protected Sub GridView1_RowCommand(.details...) Handles GridView1.RowCommand
dim status as string
Response.ContentType = "xxx/xxx"
Response.AddHeader("Content-Disposition", "attachment; Filename= filename")
Response.AddHeader("Content-Length", fileLength)
Response.BinaryWrite(bytes)
Label1.Text = "Status"
TextBox1.Text = status
UpdatePanel1.Update()
Button1_Command(sender, New CommandEventArgs("Download Status", status))
Response.End()
end sub
I have not shown all the code but it mostly works - the file is downloaded and the client page is now waiting for user input to create a new request event. What I want to do is update the TextBox and Label after the Respone.End().
I suspect the Response.End() ends the client request / event so UpDatePanel1.Update does not work. And, as you probably know, TextBox1 and Label1 are not updated with my call to Button1_Command() because the response has ended and there is no button1 "event" . I suppose I could programatically set the CommandEventArgs for the button and wait for the user to click the button to get the status but why ask the user to do that - not nice.
I tried putting the file download code in Gridview_SelectedIndexChanging which is of course followed by SelectedIndexChanged where I set TextBox1.text and did UpdDatePanel.Update(). That also did not display at client. I suspect the event that calls either RowCommand or SelectedIndexChanging is ended with the Reponse.End()
Is there a way to do what I am trying do (update browser page in the UpdatePanel without the user clicking a button or in anyway interacting with the page after the download has completed.
Perhaps some client script / server code to accomplish what I want.
Or, perhaps some type of trigger event that occurs every second, that I could enable just before updating the textbox/label then disable right after the first tick.
I have searched for an answer to this for several days now and have not found a similar situation (I.E. client has no event or response pending and the response is complete)
Links to examples or suggestions to narrow my searches would be helpful and much appreciated.
Dennis