I am integrating a Captcha control inside a CreateUserWizard.
I got the Captcha control sample code from this website here
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>
Behind code:
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
{
}
}