?
Solved

captcha control inside create user wizard.

Posted on 2009-07-07
13
Medium Priority
?
1,357 Views
Last Modified: 2012-06-27
My captcha control works great outside of the create user wizard.

But when I add it inside the wizard I cannot seem to find the control, comes back with null error.

Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles CreateUserWizard1.CreatedUser
        'Dim CaptchaControl1 As MSCaptcha.CaptchaControl = DirectCast(CreateUserWizard1.FindControl("CaptchaControl1"), MSCaptcha.CaptchaControl)
        ' Response.Write(loginCAPTCHA)
        'Dim address1 As TextBox
        Dim newBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtCap"), TextBox)
        Dim loginCAPTCHA As MSCaptcha.CaptchaControl = DirectCast(CreateUserWizard1.FindControl("CaptchaControl1"), MSCaptcha.CaptchaControl)
 
 
        loginCAPTCHA.ValidateCaptcha(Me.txtCap.Text)
        If loginCAPTCHA.UserValidated Then
            Response.Write("wrong try again")
            Return
 
        Else 
 
 
''''' asp.net
  <asp:TextBox ID="txtCap" runat="server"  ></asp:TextBox></div>
   <cc1:captchacontrol id="CaptchaControl1"   CustomValidatorErrorMessage="*Please retry to confirm you are human." runat="server" FontColor="80, 35, 114" 
        CaptchaFontWarping="Medium" CaptchaBackgroundNoise="Medium"></cc1:captchacontrol>

Open in new window

0
Comment
Question by:Seven price
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
13 Comments
 
LVL 41

Expert Comment

by:guru_sami
ID: 24798091
Did you try finding it the way like you are finding the TextBox txtCap i.e. finding inside ContentTemplateContainer:

Dim newBox As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtCap"), TextBox)

i.e.

        Dim loginCAPTCHA As MSCaptcha.CaptchaControl = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("CaptchaControl1"), MSCaptcha.CaptchaControl)
0
 
LVL 9

Author Comment

by:Seven price
ID: 24798257
Yes, I even tried a response.write to see if it shows up, Nothing.  You got anything else
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24798584
which line is throwing exception?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Author Comment

by:Seven price
ID: 24799150
well its not just that its any text box i add. Lets make it simple like this one.

Dim txtfname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfname"), TextBox)
Protected WithEvents txtfname As Global.System.Web.UI.WebControls.TextBox
 
 

cmdInsert.Parameters.Add(New SqlParameter("@fname", Data.SqlDbType.VarChar, 500))
cmdInsert.Parameters("@fname").Value = Me.txtfname.Text
 
No matter what I get a null reference
 
0
 
LVL 9

Author Comment

by:Seven price
ID: 24803593
Ok I read something about add a tb i guess to find the id. Can you help with this.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24804267
can you post your CUW code here ...to get some more idea on what exactly is going on since you are not even able to find a normal textbox..
0
 
LVL 9

Author Comment

by:Seven price
ID: 24804880
LOL I know right. Ok. Finding it in the createuserwizard is more different than just finding it by itself or in a datagrid.
I really appreciate this.

 <asp:CreateUserWizard ID="CreateUserWizard1"            
                 runat="server"  
        CreateUserButtonText="Submit">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                <ContentTemplate>
                <table><tr><td align="left">
<div align="left">
<table border="0">
<tbody align="left">
<tr>
<td align="left" colspan="2">
<asp:Label ID=top runat=server Text="Sign Up for Your New Account" Font-Bold="True" Font-Size="10pt"></asp:Label>
</td>
</tr>
<tr>
<td align="right" class="style1">
<asp:Label ID="Label1" runat="server" >First Name:</asp:Label></td>
<td align=left>
<asp:TextBox ID="fname" runat="server"></asp:TextBox>
</td>
</tr>
</table>
 
</ContentTemplate>
            </asp:CreateUserWizardStep>
          <%--  <asp:CompleteWizardStep ID="CompleteWizardStep2" runat="server">
            <ContentTemplate>      
           
            </ContentTemplate>
            </asp:CompleteWizardStep>--%>
        </WizardSteps>
    </asp:CreateUserWizard>  


Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs) Handles CreateUserWizard1.CreatedUser
        ' Get the UserId of the just-added user
        Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
 
        If Not user Is Nothing Then
            Dim userId As New Guid(user.ProviderUserKey.ToString())
 
            Dim fname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.FindControl("fname"), TextBox)
            Dim lname As TextBox = CType(CreateUserWizard1.FindControl("lname"), TextBox)
            Dim address1 As TextBox = CType(CreateUserWizard1.FindControl("address1"), TextBox)

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 2000 total points
ID: 24805113
Try using the code below exactly it is...i.e. copy+paste

 Dim fname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("fname"), TextBox)
Dim str As String = fname.Text

One more question...is your CUW control inside some other control(e.g. LoginView control ) or MasterPage
0
 
LVL 9

Author Comment

by:Seven price
ID: 24805701
The create user wizard is a login control in itself. But allows you to change the template format to a more editable control. This is what allows me to add more text boxes.  Ok i will. give me about 2 hours have a MT thanks.
0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24806001
Yes...I understand CUW is a login Control....but there is another control called LoginView control.
So I understand that CUW is not inside any other control.
0
 
LVL 9

Author Comment

by:Seven price
ID: 24808981
System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Open in new window

Line 88: System.NullReferenceException: Object reference not set to an instance of an  object.

Source Error: 

    Line 88: 
Line 89:         Dim fname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("fname"), TextBox)
Line 90:         Dim str As String = fname.Text


Line 89:         Dim fname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("fname"), TextBox)
Line 90:         Dim str As String = fname.Text

Open in new window

0
 
LVL 41

Expert Comment

by:guru_sami
ID: 24809181
not sure whats going on.....some small messed up thing...
do you mind trying with a new CUW control..
By the way what is line 88 in your code?
0
 
LVL 9

Author Comment

by:Seven price
ID: 24809817
I got it using this and it works now, Thanks.
Dim fname As TextBox = DirectCast(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtfname"), TextBox)
cmdInsert.Parameters.Add(New SqlParameter("@fname", Data.SqlDbType.VarChar, 500))

        cmdInsert.Parameters("@fname").Value = fname.Text

0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question