0
我正在將一個Captcha控件集成到CreateUserWizard中。在createuserwizard中查找Captcha控件
I got the Captcha control sample code from this website here
正如我想做的事,如果使用基於該Captcha驗證碼的用戶輸入驗證..別的...語句。 但是,當我嘗試從createuserwizard獲取Captcha控件時發生錯誤。
這裏是錯誤:
The name 'Captcha1' does not exist in the current context
我曾試圖讓這個控件作爲文本,圖像,控制但沒有成功。
下面是代碼:
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<tr>
<td class="style4">Answer:</td>
<td>
<cc1:CaptchaControl ID="Captcha1" runat="server"
CaptchaBackgroundNoise="Medium" CaptchaLength="5"
CaptchaHeight="55" CaptchaWidth="200"
CaptchaLineNoise="None" CaptchaMinTimeout="5"
CaptchaMaxTimeout="240" FontColor = "#FF33CC" CaptchaFontWarping="Medium" />
<asp:TextBox runat="server" ID="txtCaptcha" />
</td>
</tr>
</ContentTemplate>
</asp:CreateUserWizardStep>
背後代碼:
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e)
{
//Control Captcha1 = (Control)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Captcha1");
TextBox txtCaptcha = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtCaptcha");
Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim());//error occurred here
if (Captcha1.UserValidated)//error occurred here
{
}
}