Possible Duplicate:
Disabling LinkButton doesn't disable the click event in javascript
I have a linkbutton in ASP.NET.
I have set its property Enabled = false;
<asp:LinkButton ID="lnkButton" runat="server"
Enabled = "false"
OnClientClick="return confirm('Are you sure ?')" > Click Me
</asp:LinkButton>
Event thought I have set the property Enabled = false
the OnClientClick
event is still fired.
How can I prevent the OnClientClick
event from firing?
This is from Disables the link button
/// <summary>
/// Disables the link button.
/// </summary>
/// <param name="linkButton">The LinkButton to be disabled.</param>
public static void DisableLinkButton(LinkButton linkButton)
{
linkButton.Attributes.Remove("href");
linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Color] = "gray";
linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Cursor] = "default";
if (linkButton.Enabled != false)
{
linkButton.Enabled = false;
}
if (linkButton.OnClientClick != null)
{
linkButton.OnClientClick = null;
}
}
check this also how-to-enable-or-disable-linkbutton
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With