Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Hiding Div after using response.binarywrite

Posted on 2013-12-19
5
Medium Priority
?
1,586 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 41

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 41

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

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

618 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