Click here to Skip to main content
16,018,318 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
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 :

XML
<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 :

C#
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
        {

     }

}
Posted

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900