我的注册表格上有ReCaptcha控件:
<recaptcha:RecaptchaControl ID="ReCaptcha" runat="server" PublicKey="<%$ appSettings:ReCaptchaPublicKey %>" PrivateKey="<%$ appSettings:ReCaptchaPrivateKey %>" Theme="white" />
<asp:CustomValidator ID="ReCaptchaCustomValidator" runat="server" ErrorMessage="ReCaptcha error message." Display="None" ValidationGroup="Step1" EnableClientScript="true" OnServerValidate="ReCaptcha_ServerValidate" />
<asp:ValidationSummary ID="ValidationSummary1" runat="server" DisplayMode="List" ValidationGroup="Step1" CssClass="validationSummary" />
代码隐藏
protected void ReCaptcha_ServerValidate(object source, ServerValidateEventArgs e)
{
ReCaptcha.Validate();
if (ReCaptcha.IsValid)
e.IsValid = true;
else
e.IsValid = false;
}
如果用户输入的ReCaptcha值不正确,则在服务器端验证后,ReCaptcha控件将消失。
验证后如何重新加载?
答案 0 :(得分:0)
protected void Page_PreRender(object sender,EventArgs e)
{
CaptchaControl1.Enabled = true;
}