hi I have got email validation function like this below
protected void cvEmail_OnServerValidate(object sender, ServerValidateEventArgs e)
{
User objUser = new User();
string strEmail = txtEmail.Text.Trim();
// strEmail = "'" + strEmail + "'";
string strERROR = objUser.IsEmailExists(strEmail, true);
if (strERROR.Equals(string.Empty))
{
//bool passed = true;
e.IsValid = true;
if (objUser.IsEmailExistsSSO(strEmail))
{
hdnDuplicate.Value = "true";
}
else if (objUser.IsRestrictedDomain(strEmail,true))
{
e.IsValid = false;
((CustomValidator)sender).ErrorMessage = "This Email Id is found in our list of Restricted Domain";
}
if (userIdentity == null)
{
wizNewAcct.ActiveStepIndex = 2;
}
}
else
{
e.IsValid = false;
((CustomValidator)sender).ErrorMessage = strERROR;
}
}
my aim is I want call this function in below button click event
protected void btnVerifyCert_OnClick(object sender, EventArgs e)
{
if (!Page.IsValid)
{
wizNewAcct.ActiveStepIndex = 0;
return;
}
wizNewAcct.ActiveStepIndex = 1;
}
and below code is for button click aspx file
<asp:Button ID="btnVerifyCert" CssClass="btn" runat="server" OnClick="btnVerifyCert_OnClick" Text="Next >>" ValidationGroup="VerifyCert" />
code for email id
<td style="width:10%">
Email Address:
</td>
<td style="width:10%">
<asp:TextBox ID="txtEmail" runat="server" MaxLength="255" Columns="50" CssClass="txt"></asp:TextBox>
</td>
<td style="width:100px">
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" CssClass="lblError" Display="Dynamic" ErrorMessage="You did not enter an email address" ControlToValidate="txtEmail" ValidationGroup="UserInfo" Width="276px"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server" CssClass="lblError" Display="Dynamic" ErrorMessage="Please enter a valid email address" ControlToValidate="txtEmail"
ValidationExpression="^([a-zA-Z0-9])+([a-zA-Z0-9\.+_-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$" Width="277px" ></asp:RegularExpressionValidator>
<asp:CustomValidator id="CustomValidator1" runat="server" CssClass="lblError" Display="Dynamic" ControlToValidate="txtEmail" ValidationGroup="VerifyEmail"
OnServerValidate="cvEmail_OnServerValidate" Width="278px"></asp:CustomValidator>
</td>
how can I call the serverside validation function in button click event
尚未测试,但我认为问题是btnVerifyCert_OnClick
具有ValidationGroup="VerifyCert"
和CustomValidator1
具有ValidationGroup="VerifyEmail"
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.