I'm trying to add a textbox to the initial step of the CreatUserWizard.
Let's say it is tbMyTextbox.
Now when I add an event on created user, I want to get the value in the field.
I thought I could use
dim mc as textbox
mc = ctype(CreateUserWizard1.Findcontrol("tbMyTextbox"),textbox)
mc.text should be the text of the field.
But it can't find the control... so I tried
dim mystep as CreatuserWizardstep
mystep = createuserwizard1.activestep
mc = ctype(mystep.findcontrol("tbMyTextbox"),textbox)
But it also fails.
The example just uses tbMyTextbox.text which just throws a compiler error.
Anyone have any other ideas.

Adding fields to the CreateUserWizard
josh55
Hi Guy,
I have solved my problem by doing the following within the OnCreatedUser Event function:-
Dim
UserNameTxt As TextBox = _ CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)I remark this original statement that always show UserName = "".
'Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName.ToString())
Change to this.
Dim user As MembershipUser = Membership.GetUser(UserNameTxt.Text)
It work now.
Bye Bye
Maor
Hi Expert,
I encountered the OnCreatedUser Event problem when getting the UserName. System always show "" for the CreateUserWizard1.UserName.
I am trying to update the extra fields value at this event.
Please advice.
Gerfboy
Web Platform & Tools Team
He amswered this a while back in a bug report:
The way to get to a reference to a child control in a WizardStep is:
TextBox txtFirstName = (TextBox) CreateUserWizard1.WizardSteps[1].FindControl("FirstNameTextBox");
Profile.FirstName = txtFirstName.Text;
Your suggested approach to call CreateUserWizard1.FirstNameTextBox doesn't work because "FirstNameTextBox" is not a property of the class CreateUserWizard.
Here is one additional thing to keep in mind: if you try to access controls from our special CreateUserWizardStep (the one that automatically puts the username, password, and so forth), then the code is different to actually access the inner controls. If that is the case, then its going to be like this: CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("TextBox1"), TextBox)
I know its a little bit confusing, the thing is that there are 2 types of steps that you can add to a wizard: a WizardStep and a TemplateWizardStep. If you are trying to access controls that are in a WizardStep you use the code that I sent you first; if you are trying to access controls from a TemplateWizardStep you use the one above.
GaetanoDiGregorio
I think I understand how to add the text boxes I need to the form but I am lost when it comes to saving the data to a table in my sql 2000 database. I have actually added the columns I need to the aspnet users table.
Any suggestions on how to get this done
bclark
Hi
Using SQLDataSource I've been successful in creating multiple additional CreateUser fields saving them to "tbl_UserDetails" table. I pass the UserId to the tbl_UserDetails as well. What I'm struggling with is retreiving the new tbl_UserDetails "Details_Id" - I want to integrate it into the Profile data. I'm not sure if the problem retreiving the Details_Id is in the SQLDSInsert_Inserted code used or if I'm not addressing the retreival in the "correct" stage of "the process". See below.
Thanks
Imports Telerik.WebControls
Imports SITE.DAL.DBAccess
Imports System.Data
Imports System.Data.SqlClient
Partial Class Site_Pages_Registration
Inherits System.Web.UI.Page
Protected WithEvents Update_Date As WebControls.HiddenField
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("Record") IsNot Nothing Then
CreateUserWizard1.MoveTo(CompleteWizardStep1)
End If
End Sub
Protected Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As System.EventArgs) Handles CreateUserWizard1.CreatedUser
Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
If user Is Nothing Then
Throw New ApplicationException("Can't find the user.")
End If
Dim DetailsInsert As SqlDataSource = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SQLDSInsert"), SqlDataSource)
Dim UserId As Guid = DirectCast(user.ProviderUserKey, Guid)
Session("NewUserId") = UserId
Dim Details_FirstName As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_FirstName"), TextBox)
Dim Details_LastName As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_LastName"), TextBox)
Dim Details_MI As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_MI"), TextBox)
Dim Details_Title As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Title"), TextBox)
Dim Details_Company As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Company"), TextBox)
Dim Details_1Comm As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox)
Dim Details_1CommType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox)
Dim Details_2Comm As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox)
Dim Details_2CommType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox)
Dim Details_Address As TextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Address"), TextBox)
Dim Details_City As TextBox = CType(CreateUserWizardStep0.ContentTemplateContainer.FindControl("Details_City"), TextBox)
Dim Details_State As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox)
Dim Details_Zip As Telerik.WebControls.RadMaskedTextBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox)
Dim Details_UserTypeId As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_UserTypeId"), Telerik.WebControls.RadComboBox)
Dim Details_ReceiveEmail As CheckBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_ReceiveEmail"), CheckBox)
DetailsInsert.Insert()
Dim UserType As Telerik.WebControls.RadComboBox = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_UserTypeId"), Telerik.WebControls.RadComboBox)
Session("UserType") = UserType.SelectedValue.ToString
End Sub
Protected Sub SQLDSInsert_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
e.Command.Parameters("@UserId").Value = user.ProviderUserKey
e.Command.Parameters("@Details_FirstName").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_FirstName"), TextBox).Text
e.Command.Parameters("@Details_LastName").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_LastName"), TextBox).Text
e.Command.Parameters("@Details_MI").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_MI"), TextBox).Text
e.Command.Parameters("@Details_Company").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Company"), TextBox).Text
e.Command.Parameters("@Details_Title").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Title"), TextBox).Text
e.Command.Parameters("@Details_1Comm").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox).Text
e.Command.Parameters("@Details_1CommType").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox).SelectedValue
e.Command.Parameters("@Details_2Comm").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox).Text
e.Command.Parameters("@Details_2CommType").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox).SelectedValue
e.Command.Parameters("@Details_Address").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Address"), TextBox).Text
e.Command.Parameters("@Details_City").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_City"), TextBox).Text
e.Command.Parameters("@Details_State").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox).SelectedValue
e.Command.Parameters("@Details_Zip").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox).Text
e.Command.Parameters("@Details_UserTypeId").Value = Int32.Parse(CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_UserTypeId"), Telerik.WebControls.RadComboBox).SelectedValue)
e.Command.Parameters("@Details_ReceiveEmail").Value = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_ReceiveEmail"), CheckBox).Checked
End Sub
Protected Sub CompleteButton_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
Dim pb As ProfileBase = ProfileBase.Create(user.UserName)
pb.SetPropertyValue("FirstName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_FirstName"), TextBox).Text)
pb.SetPropertyValue("LastName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_LastName"), TextBox).Text)
pb.SetPropertyValue("UserName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox).Text)
pb.SetPropertyValue("Record", Session("Record"))
pb.SetPropertyValue("Company", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Company"), TextBox).Text)
pb.SetPropertyValue("Title", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Title"), TextBox).Text)
pb.SetPropertyValue("Comm1", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.SetPropertyValue("Comm1Type", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Comm2", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.SetPropertyValue("Comm2Type", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Address", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Address"), TextBox).Text)
pb.SetPropertyValue("City", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_City"), TextBox).Text)
pb.SetPropertyValue("State", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Zip", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.Save()
Dim lblRegisterCompleteName As Label = CreateUserWizard1.CompleteStep.FindControl("lblRegisterCompleteName"), Label
lblRegisterCompleteName.Text = Profile.FirstName & " " & Profile.LastName
Dim Muser As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
If Muser Is Nothing Then
Throw New ApplicationException("Can't find the user.")
End If
Muser.IsApproved = False
End Sub
Protected Sub btnTeamProfile_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim user As MembershipUser = Membership.GetUser(CreateUserWizard1.UserName)
Dim pb As ProfileBase = ProfileBase.Create(user.UserName)
pb.SetPropertyValue("FirstName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_FirstName"), TextBox).Text)
pb.SetPropertyValue("LastName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_LastName"), TextBox).Text)
pb.SetPropertyValue("UserName", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox).Text)
pb.SetPropertyValue("Record", Session("Record"))
pb.SetPropertyValue("Company", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Company"), TextBox).Text)
pb.SetPropertyValue("Title", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Title"), TextBox).Text)
pb.SetPropertyValue("Comm1", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.SetPropertyValue("Comm1Type", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_1CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Comm2", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2Comm"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.SetPropertyValue("Comm2Type", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_2CommType"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Address", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Address"), TextBox).Text)
pb.SetPropertyValue("City", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_City"), TextBox).Text)
pb.SetPropertyValue("State", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_State"), Telerik.WebControls.RadComboBox).SelectedValue)
pb.SetPropertyValue("Zip", CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Details_Zip"), Telerik.WebControls.RadMaskedTextBox).Text)
pb.Save()
Response.Redirect("Profile.aspx")
End Sub
Protected Sub CompleteWizardStep1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles CompleteWizardStep1.PreRender
Dim btnTeamProfile As Button = CType(CompleteWizardStep1.ContentTemplateContainer.FindControl("btnTeamProfile"), Button)
If Session("UserType") = "2" Then
btnTeamProfile.Visible = True
Else
btnTeamProfile.Visible = False
End If
End Sub
Protected Sub SQLDSInsert_Inserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs)
Dim DetailsInsert As SqlDataSource = CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SQLDSInsert"), SqlDataSource)
Dim Record As Integer = DetailsInsert.InsertParameters.Add("@Details_Id", System.Data.ParameterDirection.ReturnValue)
'Dim Record As Integer = e.Command.ExecuteScalar
Session("Record") = Record.ToString
Response.Redirect("Registration.aspx")
End Sub
End Class