I have Validation control that validates user input on TextBox control.
Also there is LinkButton on my form with OnClick event handler defined.
Now when LinkButton is clicked and Validation condition is not met then OnClick handler of LinkButton is not invoked.
Why is this happening?
How does the Validation ctrl. suppreses OnClick event of LinkButton ctrl?
When Validation condition on TextBox is OK then all works as expected.
Here is page to illustrate this:
<%@ Page Language="C#" %>
<script Language="C#" runat="server">
protected void LinkButton1_Click(object sender, EventArgs e)
int x = 1;
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">LinkButton</asp:LinkButton></div>
This code does not do anything smart, it is just for testing.
Try putting breakpoint on line "int x = 1;" to see this behavior.