HTML
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
Codebehind
protected void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("onclick", (ClientScript.GetPostBackEventReference(Button1, "") + ";this.value=\'Loading...\';this.disabled = true;"));
}
class Default_ : System.Web.UI.Page
{
protected void Button1_Click(object sender, System.EventArgs e)
{
System.Threading.Thread.Sleep(555);
//Some additional logic here
** Without Masterpage **
ClientScript.RegisterClientScriptBlock( this.GetType(), "reset",
("document.getElementById(\'" + (Button1.ClientID + "\').disabled=false;")), true);
** With Masterpage **
ScriptManager.RegisterClientScriptBlock(this,true.GetType(), "reset",
("document.getElementById(\'" + (Button1.ClientID + "\').disabled=false;")), true);
}
}
NOTE : This will not work if you are using UpdatePanel. If you are using UpdatePanel, see here.
Ref:
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
Codebehind
protected void Page_Load(object sender, System.EventArgs e)
{
Button1.Attributes.Add("onclick", (ClientScript.GetPostBackEventReference(Button1, "") + ";this.value=\'Loading...\';this.disabled = true;"));
}
class Default_ : System.Web.UI.Page
{
protected void Button1_Click(object sender, System.EventArgs e)
{
System.Threading.Thread.Sleep(555);
//Some additional logic here
** Without Masterpage **
ClientScript.RegisterClientScriptBlock( this.GetType(), "reset",
("document.getElementById(\'" + (Button1.ClientID + "\').disabled=false;")), true);
** With Masterpage **
ScriptManager.RegisterClientScriptBlock(this,true.GetType(), "reset",
("document.getElementById(\'" + (Button1.ClientID + "\').disabled=false;")), true);
}
}
NOTE : This will not work if you are using UpdatePanel. If you are using UpdatePanel, see here.
Ref:
No comments:
Post a Comment