Click here to Skip to main content
15,908,775 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the UseSubmitBehaviour Property of Button. when click on the Button, before click event , i m using OnClickClick function of Button, here i am disabling the Button and changed the Text of Button to Please Wait.. . after complete the click event action, it automatically comes to the previous state, The Button is enabled and the Text of Button changed to Submit.

Now my problem which i am facing in this process is that

When on button click , i am adding the Excel Download code, after complete the click event action, it does not come to the previous state, means it only remains as 'Please Wait.' and the button remain disabled. how to do it ? Please Help

What I have tried:

ASP.NET
<asp:Button ID="btnGetData" runat="server" Text="Get Data" CssClass="btn" style="width:auto; padding:3px 7px;" UseSubmitBehavior="false" CausesValidation="false" 
                        OnClientClick="this.disabled=true; this.value='Please Wait..';" />



on button click :

VB
Try
           Dim excel_name As String = "E2E Report"
           HttpContext.Current.Response.Clear()
           HttpContext.Current.Response.ClearContent()
           HttpContext.Current.Response.ClearHeaders()
           HttpContext.Current.Response.Buffer = True
           HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"
           HttpContext.Current.Response.Write("<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">")
           HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + excel_name + "(" + System.DateTime.Now + ").xls")

           HttpContext.Current.Response.Charset = "utf-8"
           HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250")
           'sets font
           HttpContext.Current.Response.Write("<font style="font-size: 10.0pt; font-family: Calibri">")
           HttpContext.Current.Response.Write("<br><br><br>")
           'sets the table border, cell spacing, border color, font of the text, background, foreground, font height
           HttpContext.Current.Response.Write("")
           'am getting my grid's column headers
           Dim columnscount As Integer = GridView1.Columns.Count

           For j As Integer = 0 To columnscount - 1
               'write in new column
               HttpContext.Current.Response.Write("")
           Next
           HttpContext.Current.Response.Write("")
           For Each row As DataRow In table.Rows
               'write in new row
               HttpContext.Current.Response.Write("")
               For i As Integer = 0 To table.Columns.Count - 1
                   HttpContext.Current.Response.Write("")
               Next

               HttpContext.Current.Response.Write("")
           Next
           HttpContext.Current.Response.Write("<table border="1" cellspacing="0" cellpadding="0"> <tbody><tr><td>")
               'Get column headers  and make it as bold in excel columns
               HttpContext.Current.Response.Write("")
               HttpContext.Current.Response.Write(GridView1.Columns(j).HeaderText.ToString())
               HttpContext.Current.Response.Write("")
               HttpContext.Current.Response.Write("</td></tr><tr><td>")
                   HttpContext.Current.Response.Write(row(i).ToString())
                   HttpContext.Current.Response.Write("</td></tr></tbody></table>")
           HttpContext.Current.Response.Write("</font>")
           HttpContext.Current.Response.Flush()
           HttpContext.Current.Response.[End]()
       Catch ex As Exception

       End Try
Posted
Updated 29-Oct-16 3:10am
v2

1 solution

Simple. Do everything server side. Inside the server click event, first line should disable the button and second line should set the Button's Text property.

Then at the end, do the reverse to make it enabled and text to normal.
 
Share this answer
 

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