javascript - Run script after file download -
in asp.net mvc application have button on view , on click event returns action is
public void exporttoexcel() { string startdate = convert.todatetime(session["datestart"]).tostring("yyyy-mm-dd"); string enddate = convert.todatetime(session["dateend"]).tostring("yyyy-mm-dd"); int hierarchyid = convert.toint32(session["hierarchyid"]); databasemanager dbmanager = new databasemanager(); sqlconnection connection = new sqlconnection(dbmanager.getconnectionstring()); sqlcommand command = new sqlcommand("rpt_getemptimeboardforperiodandhierarchyposition", connection); command.commandtype = commandtype.storedprocedure; command.parameters.add(new sqlparameter("startdate", startdate)); command.parameters.add(new sqlparameter("enddate", enddate)); command.parameters.add(new sqlparameter("hierarchyid", hierarchyid)); command.commandtimeout = 360; connection.open(); datatable dt = new datatable(); dataset ds = new dataset(); sqldataadapter da = new sqldataadapter(command); da.fill(dt); gridview gv = new gridview(); gv.datasource = dt; gv.databind(); stringwriter sw = new stringwriter(); htmltextwriter htw = new htmltextwriter(sw); gv.rendercontrol(htw); response.clearcontent(); response.buffer = true; response.addheader("content-disposition", string.format("attachment; filename=tabelfor_{0}-{1}.xls", convert.todatetime(session["datestart"]).tostring("dd.mm.yyyy"), convert.todatetime(session["dateend"]).tostring("dd.mm.yyyy"))); response.contenttype = "application/ms-excel"; response.charset = ""; viewbag.alertmessage = "download completed"; response.output.write(sw.tostring()); response.flush(); response.end(); }
i can disable button when it's been clicked, how can enable when file has been downloaded. thank's in advance.
i believe should trigger window load event can bind handler enable button it, that
$(document).load(function(){ $('#buttonid').prop("disabled", false); });
please note didn't had chance test scenario , might require make tweaks before works.
hope helps!
Comments
Post a Comment