Reputation:
I tried to disable an asp.net button but failed. The error:
Compiler Error Message: CS1501: No overload for method 'btnUnlock_Click' takes '0' arguments
Source Error:
Line 99: <asp:Button ID="btnUnlock" runat="server" Text="Unlock User" Visible="False" OnClick ="btnUnlock_Click()" />
And
protected void btnUnlock_Click(object sender, EventArgs e)
{
MembershipUser user = Membership.GetUser(userName);
user.UnlockUser();
}
Thanks.
Upvotes: 2
Views: 13095
Reputation: 22076
Use OnClientClick="return false;"
to disabled postback. You can try this
<asp:button runat="server".... OnClientClick="return false;" />
In C# you can disable button by
btnUnlock.IsEnabled = false;
Upvotes: 8
Reputation: 78840
Two problems here:
OnClick="btnUnlock_Click()"
This syntax is incorrect. To set up your server-side click handler, write it like this:
OnClick="btnUnlock_Click"
Also, your question title doesn't seem to relate to this code at all. If you're wanting to know how to disable the server-side click handling client-side, you can add a client-side click handler, like this:
OnClientClick="return false;"
...or some custom client-side function. To disable it server-side, simply don't add the OnClick
attribute.
Upvotes: 0