c# - How to hide UpdateProgress Image -


i have 1 ajax updateprogress many updatepanels in page. 1 of updatepanel's has gridview download button. once user clicks on button, 'wait' image shows up, keeps showing after download complete.

how should hide it, once download done.

aspx:

<asp:updateprogress id="updateprogress1"  runat="server" displayater="1">     <progresstemplate>         <asp:image id="imgwait" runat="server" imageurl="~/images/wait.gif"/>     </progresstemplate>   </asp:updateprogress> 

js:

function hideimage() {     $(#imgwait).hide(); } //also tried //sys.webforms.pagerequestmanager.getinstance().add_endrequest(endrequesthandler);  //function endrequesthandler(sender, args) //{ //   document.getelementbyid('<%=imgwait.clientid%>').classname = 'hidden'; //} 

code behind:

protected void download(object sender, commandeventargs e) {     string sfile = e.commandargument.tostring();     response.redirect("download.aspx?file="+sfile,false);     scriptmanager.registerstartupscript(this.page,this.gettype(),                                     "script","hideimage();",true); } 

download.aspx

page_load() {     if(!string.isnullorempty(request.querystring["file"]))     {         string path = server.mappath(request.querystring["file"]);         system.io.fileinfo file = new system.io.fileinfo(path);         if ( file.exists )            {             response.clear();             response.addheader("content-disposition", "attachment; filename=" +                                 file.name);             response.addheader("content-length", file.length.tostring());             response.contenttype = "application/octet-stream";             response.writefile(file.fullname);             response.flush();             response.end();         }     } } 

you redirecting page downloads file, think screen doesn't update in case, image stays.

you either make file download on same page or make redirect via script after postback:

protected void download(object sender, commandeventargs e) {     string sfile = e.commandargument.tostring();     string script = "location.href='download.aspx?file=" + sfile + "';";     scriptmanager.registerstartupscript(this.page,this.gettype(),                                     "script",script,true); } 

in case, "hideimage()" script not needed, postback complete successfully.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -