Solved

captcha control inside create user wizard.

Posted on 2009-07-07
13
1,349 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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

696 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