i am using custom validator on one of my web form, the requirement is to check for the bookcode in the database and if it exists, then it should display message, now i am using custom validator for the same, what i want is, it should not postback if the custom validator returns false, instead it should act like normal validator and display message, i am using ServerSide Validation for the custom validator. here my code goes.
HTML Markup
<asp:TextBox ID="BookCode" runat="server" CssClass="textEntry"></asp:TextBox>
<asp:CustomValidator ID="BookCodeCustomValidator" runat="server" ControlToValidate="BookCode" CssClass="failureNotification fr"
Display="Dynamic" ErrorMessage="Book already exists (Book Code should be unique)." OnServerValidate="ServerValidation"
ToolTip="Book already exists (Book Code should be unique)." ValidationGroup="AddFacBookValidationGroup"></asp:CustomValidator>
and here is my code behind looks like
protected void ServerValidation(object sender, ServerValidateEventArgs e)
{
objAddBooks.LibraryInfo = Transactions.LibraryFields.Bookcode;
objAddBooks.Criteria = BookCode.Text;
e.IsValid = (objAddBooks.BookExists) ? false : true;
}