Stop Postback in Image Button after validation failed
<p>I have a aspx page containing a text box and an image button for search. I have used compare validator (to check for integer values) with the textbox. But the page reloads on the image button click even if I enter alphanumeric characters, along with showing the error message.</p>

<p>I tried using a regularexpressionvalidator instead but the problem persists.</p>

<p>But when i used a simple asp:button instead and binded it with textbox validation, its working fine (i.e. postback does not occur on incorrect value of textbox) and same is true with dropdownlist also (no postback occuring).</p>

<p>Please suggest.</p>

<p>Here's the code-</p>

<p>@peroija : Here's the code </p>

<pre><code>&lt;asp:ImageButton ID="btnSearch" runat="server" OnClick="btnSearch_Click" 
    ToolTip="Search" ValidationGroup="valControl" CausesValidation="true" /&gt;
&lt;asp:TextBox ID="txtWidth" CssClass="TextFont" runat="server" 
    Width="233px" MaxLength="20" 
    ValidationGroup="valControl" CausesValidation="true"&gt;&lt;/asp:TextBox&gt;
&lt;asp:CompareValidator runat="server" ID="cmpValWidth" 
    ErrorMessage="Please enter integer values" ControlToValidate="txtWidth" Display="Dynamic" 
    Operator="DataTypeCheck" ValidationGroup="valControl"Type="Integer"/&gt;
</code></pre>
