joecool2005 Posted October 24, 2007 Share Posted October 24, 2007 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 More sharing options...
aspnetguy Posted October 24, 2007 Share Posted October 24, 2007 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 More sharing options...
joecool2005 Posted October 24, 2007 Author Share Posted October 24, 2007 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? Link to comment Share on other sites More sharing options...
jesh Posted October 26, 2007 Share Posted October 26, 2007 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.