protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
Recaptcha.RecaptchaControl mycaptcha = (Recaptcha.RecaptchaControl)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("RecaptchaControl1");
mycaptcha.Validate();
Boolean answer = mycaptcha.IsValid;
if (answer == false)
{
((CancelEventArgs)e).Cancel = true;
}
}
上面是我的验证Google Recapture的代码,我在Visual Studio上使用CreateUserWizard
表单。
代码没问题,直到我运行它并出现错误
An exception of type 'System.NullReferenceException' occurred in App_Web_whsxk5eb.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
代码行mycaptcha.Validate();
我不确定如何修复它。