?
Solved

Hiding Div after using response.binarywrite

Posted on 2013-12-19
5
Medium Priority
?
1,558 Views
Last Modified: 2014-01-08
I have one function which is downloading the excel file on browser. I need to show the progress bar to the end user till the time excel not downloaded and hide the same once downloaded. Issue is i am not able to hide the progress bar. Below is the code snippet i am using

<div id="progressbar" runat="server" align="center" style="display:none;position: fixed; z-index: 9; float: left; width: 848px; top: 224px; left: 32px;">
                <img alt="progress" src="images/loading.gif"/>                                      
            </div>

<asp:LinkButton ID="LinkButton1" OnClientClick="showprogressbar();" runat="server" onclick="LinkButton1_Click">Click here</asp:LinkButton>

function showprogressbar()
          {
              document.getElementById('<%= progressbar.ClientID%>').style.display = '';

            }

Server site code snippet

 public void Downloadlogfile()
    {
Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "filename=" + st + ".xls");
        Response.Clear();
        Response.BinaryWrite(WriteToStream().GetBuffer());
}

protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Downloadlogfile();  
    }
0
Comment
Question by:vikalgupta
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39731187
Two ways I can think of:

1)
    Use a timer.  On the timer_tick event, hide the div.  Start the timer before response.binarywrite()

2)  Use a RegisterStartupScript to call a JS function that will hide the div for you.  (After the response.clear ).
0
 

Author Comment

by:vikalgupta
ID: 39731219
I tried 2 option but javascript is not firing.
 ClientScript.RegisterStartupScript(this.GetType(), "HideDiv", "$('#progressbar').style.display='none';", true);
0
 
LVL 40

Expert Comment

by:Kyle Abrahams
ID: 39732255
Try just an alert function to see if it's the javascript or if it's the register startup script.

I ended up using a timer in my app but forget why . . . you may need that second postback in order for it to work.
0
 
LVL 7

Accepted Solution

by:
Kishan Zunjare earned 1500 total points
ID: 39753559
Hi

In .Net 4.5 version new keyword "async" and "await" provided for asynchronous programming.
You can use here.. for more info - http://msdn.microsoft.com/en-us/library/hh191443.aspx

Hope this helps.

- Kishan
0
 

Author Closing Comment

by:vikalgupta
ID: 39764746
Good
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question