Getting the value out of the control contained in CreateUserWizard Control

I was using CreateUserWizard to create a user. I changed the control so that it contained custom TextBoxes. Now I wanted to get the value out of the TextBoxes. The first approach I tried was the following (offcourse it did not worked!).

TextBox firstNameTextBox = (TextBox) CreateUserWizard1.FindControl("txtFirstName");

This will always return null why? Well it returns null since the TextBox is not contained inside the CreateUserWizard control but its inside a template contained by the CreateUserWizard control. You can easily retrieve the values out of the control using the following code: 

string firstName = ((TextBox)CreateUserWizard1.CreateUserStep
.ContentTemplateContainer.FindControl("txtFirstName")).Text;
        

string lastName = ((TextBox)CreateUserWizard1
        .CreateUserStep.ContentTemplateContainer
        .FindControl("txtLastName")).Text;


               
 

 

 

powered by IMHO 1.3

Print | posted @ Friday, February 17, 2006 7:54 PM

Twitter