在createuserwizard中查找Captcha控件 [英] Finding Captcha control inside createuserwizard
本文介绍了在createuserwizard中查找Captcha控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将Captcha控件集成到CreateUserWizard中.
因为我想使用if .. else ..语句根据验证码对用户的输入进行验证.但是,当我尝试从createuserwizard获取Captcha控件时发生错误.
这是错误:
The name ''Captcha1'' does not exist in the current context
我曾尝试将此控件作为文本框,图像,控件获取,但未成功.
这是代码:
< asp:CreateUserWizardStep ID =" ID span> runat =" 服务器" < ContentTemplate >
< tr >
< td =" style4" < >
< td >
< cc1:CaptchaControl ID =" runat 服务器"
CaptchaBackgroundNoise ="
CaptchaLength ="
CaptchaHeight ="
CaptchaWidth ="
CaptchaLineNoise ="
CaptchaMinTimeout ="
CaptchaMaxTimeout ="
FontColor =" #FF33CC"
CaptchaFontWarping =" / >
< asp:TextBox 运行 =" ID txtCaptcha " / < /td >
< /tr >
< /ContentTemplate >
< /asp:CreateUserWizardStep >
这是后面的代码:
受保护的 无效 CreateUserWizard1_CreatedUser(对象发件人,EventArgs e)
{
// 控件Captcha1 =(Control)CreateUserWizardStep1.ContentTemplateContainer.FindControl("Captcha1");
TextBox txtCaptcha =(TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl(" );
Captcha1.ValidateCaptcha(txtCaptcha.Text.Trim()); // 此处发生错误
如果(Captcha1.UserValidated)// 此处发生错误
{
}
}
解决方案
在这里,请看类似的讨论:向导向导中的验证码 [ ^ ]
以下MSDN文章将帮助您自定义向导控件: MSDN:如何:自定义ASP.NET CreateUserWizard控件 [ ^ ]
I am integrating a Captcha control inside a CreateUserWizard.
As I wanted to do a validation for user''s input based on the Captcha using an if.. else.. statement. However an error occured when I trying to get the Captcha control from the createuserwizard.
Here the is error :
The name ''Captcha1'' does not exist in the current context
I had tried to get this control as a textbox, image, control but it was not successful.
Here is the code :
<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>
Here is the code at the behind :
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
{
}
}
解决方案
Here, look at similar discussion: Captcha inside Wizard control[^]
Following MSDN article will help you in customizing Wizard control: MSDN: How to: Customize the ASP.NET CreateUserWizard Control[^]
这篇关于在createuserwizard中查找Captcha控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文