Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have googled around for half day searching for the answer but no success. Im trying my luck here.

My aspx does not have update panel.
I succeed to show progress bar after user click Export to Excel but it never hides back after Respond.End.
Is there any method to solve the problem?

Here's the codes:

Javascript to show progress bar
XML
<script src="jquery-1.8.3.min.js" type="text/javascript"></script>
   <script type="text/javascript">
       function ShowProgress() {
           setTimeout(function () {
               var modal = $('<div />');
               modal.addClass("modal");
               $('body').append(modal);
               var loading = $(".loading");
               loading.show();
               var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
               var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
               loading.css({ top: top, left: left });
           }, 200);


       }
       $('form').live("submit", function () {
           ShowProgress();
       });



   </script>


Code behind (Page Load)
ClientScript.RegisterStartupScript(Me.[GetType](), "load", "$(document).ready(function () { $('[id*=btnExport]').click(); });", True)


Code behind (Export to Excel)
VB
Dim style As String = "<style> .text { mso-number-format:'#,##0.000_);[Red](#,##0.000)';text-align:right; } </style> "

            HttpContext.Current.Response.Clear()
            HttpContext.Current.Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", fName))
            HttpContext.Current.Response.ContentType = "application/ms-excel"
            HttpContext.Current.Response.ClearContent()
            HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode
            HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble())
            HttpContext.Current.Response.Write(style)

            Using sw As New StringWriter()
                Dim hw As New HtmlTextWriter(sw)

                'To Export all pages

                For Each row As GridViewRow In gv.Rows
                    'For Each cell As TableCell In row.Cells
                    For i As Integer = 0 To row.Cells.Count - 1
                        Dim str As String = row.Cells(i).Text
                        If i > 7 Then
                            row.Cells(i).Attributes.Add("class", "text")
                        End If
                    Next
                Next

                pnl.RenderControl(hw)

                HttpContext.Current.Response.Write(sw.ToString())

            End Using


            HttpContext.Current.Response.Flush()
            HttpContext.Current.Response.SuppressContent = True
            HttpContext.Current.ApplicationInstance.CompleteRequest()
            Response.[End]()
Posted
Updated 31-Jul-15 19:25pm
v2

1 solution

You probably need to provide full sources so we can debug it for u.
and i've posted your question here:How to Show/Hide Loading Image after Export to Excel without using Update Panel[^]

hope that helps. :)
 
Share this answer
 
Comments
Richard Deeming 3-Aug-15 17:05pm    
Don't copy other people's questions and post them on other sites!

And don't post comments as new solutions. There's a "Have a Question or Comment?" button underneath each question and solution - use that instead.
YassineYousfi 3-Aug-15 17:29pm    
ok, sorry wont copy any more questions, i just thought it would be helpful for that guy...i am new to CodeProject questions&answer thing :) sorry !!!
snamyna 5-Aug-15 21:36pm    
Thanks guys. My full sources is too long. I just provide codes that related to the function I required help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900