troubleshooting Question

Asp.net - C# - Disable button / lock screen after download is complete on the browser

Avatar of Explorer JK
Explorer JK asked on
ASP.NETC#XML
4 Comments2 Solutions1140 ViewsLast Modified:
Hi,

I am using xmlwriter to create XML document  from excel, I am able to create XML document and able to provide an option to the user to save the file on their computer.

However when download completes the form is still open and all button are accessible. I would ideally like to disable  the "Btn_Process " btn when the download starts or ends , I have used the option to disable to the button at all stages on click event of the button and also below in the finally statement , but the btn does not get disabled.

I would like any of the following :
1. Disable button Btn_Process on click of the btn or after the download completes
2. Lock screen when downloading is in progress then unlock
3. Redirect to the same page after download is complete

Thanks in Advance

The code is as follows:
try
                {
                    CreateXML(TableA, TableB);   //Call Create XML Method 
                }
                catch (Exception e) { //Ex catch}
                finally
                {
                    Btn_Process.Enabled = false;
                    HttpContext.Current.Response.End();
                    Server.Transfer("Excel2XML.aspx");
                    
                }

The above CreateXML method has the below xmlwriter For creating the XML file :
           
string name = string.Format("attachment; filename=HDCLv1_NYC_{0:yyyyMMddHHmmss}.xml", DateTime.Now);
            HttpContext.Current.Response.ContentType = "application/xml";
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            HttpContext.Current.Response.BufferOutput = false; 
            HttpContext.Current.Response.AppendHeader("Content-Disposition", name);

 using (XmlWriter writer = XmlWriter.Create(HttpContext.Current.Response.OutputStream, settings)) {  

                writer.Flush();
                writer.Close();
                HttpContext.Current.Response.Flush();
ASKER CERTIFIED SOLUTION
Explorer JK

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros