Jump to content

disabled button


joecool2005

Recommended Posts

Hi,On this code

		Sub signed(ByVal Sender As Object, ByVal E As EventArgs)			Button1.Enabled = False			Response.Redirect("signConfirmPage.aspx")		End Sub<asp:Button id=Button1 Text="   OK   " runat="server" Enabled=false OnClick="signed"  />

When the user clicks, it will take a few seconds to redirect. While the page is waiting to be redirected, why my button is not disabled before it redirect?If I remove the Response.Redirect("signConfirmPage.aspx"), I'll see the disabled button.Plz helpThx

Link to comment
Share on other sites

both the disabling of the button and the redirect are processed on the server. The server doesn't send response back to the browser until the postback function is complete. However, the redirect immediately does the redirect and everything that comes after (the updating of the current page) is not executed.To do what you want do this.

Sub Page_Load (......)	Button1.Attributes.Add("onclick","this.disabled=true")End SubSub signed(ByVal Sender As Object, ByVal E As EventArgs)	Response.Redirect("signConfirmPage.aspx")End Sub<asp:Button id=Button1 Text="   OK   " runat="server" OnClick="signed"  />

Link to comment
Share on other sites

Thanks for your help.I just try it.Now I can see that the button is disabled. But it does not redirect.If I remove the disabled function, the page will redirect.Why?
Like aspnetguy said, the disabling and the redirecting are both happening on the server. And, when a control is disabled, no click event is broadcast when you click on the button and your click event handler (the code where you tell the request to redirect) never fires.If you want the button to appear to be disabled and then, after some delay, redirect the user to some other page, then you'll need to use client-side scripting to perform that.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...