Cannot find server control

bjhuang

New Member
I'm new at ASP.NET but something that continuously gives me trouble is finding nested server controls, especially when they are nested. In this case, here is my registration page up until the server control I want:\[code\]<asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser"> <LayoutTemplate> <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /> <asp:PlaceHolder runat="server" ID="navigationPlaceholder" /> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"> <ContentTemplate> <fieldset> <ol> <li> <asp:TextBox runat="server" ID="firstName" /> </li>\[/code\]For readability sake, the only things I've removed are some HTML elements. I am trying to access'firstName'. I've tried all of the following with no luck, (TextBox first is always coming up null).\[code\]TextBox first = (TextBox)Page.Master.FindControl("MainContent").FindControl("firstName");TextBox first = (TextBox)Page.FindControl("firstName");TextBox first = (TextBox)RegisterUserWizardStep.FindControl("firstName");TextBox first = (TextBox)RegisterUser.FindControl("firstName");\[/code\]Would appreciate help, thanks!
 
Back
Top