I am using custom validation. my problem is on save button data is inserted in table. e.isvalid=false in this case also data is inserted and in other case also. how can i use custom validation. so that if validation occurs data should not enter database.
.aspx
<asp:CustomValidator ID="cv_login" runat="server" ValidationGroup="add" Enabled="true" ControlToValidate="txt_username" OnServerValidate="cv_login_validate"></asp:CustomValidator>
.cs
protected void cv_login_validate(object sender, ServerValidateEventArgs e)
{
............
........
if (temp > 0)
{
e.IsValid = false;
}
else
{
e.IsValid = true;
}
}
button code
<asp:Button ID="btn_save" runat="server" Font-Bold="true" Text="Save"
onclick="btn_save_Click" ValidationGroup="add" style="height: 26px" CausesValidation="true"/>