Using ASP.Net Membership and CreateUserWizard, I noticed I am unable in code retrieve the values for Passoword, UserName, ConfirmPassword, etc. I am able to retieve extended extended properties.
Wondering if possible to retrieve UserName, etc. I have included sample code below. When the fields are filled in and postback, I am able to reference Password, ConfirmPassword, Email, and UserName, but the value received are empty strings. I am able to reach the Title field's value, which the Title field doesn't return an empty string. The code below is only a subset.
<asp:CreateUserWizard ID="UserRegistration" runat="server"
onload="UserRegistration_Load" onprerender="UserRegistration_PreRender">
<WizardSteps>
<asp:CreateUserWizardStep ID="UserRegistrationStep_1" runat="server">
<ContentTemplate>
<asp:Label ID="lblUserName" runat="server" Text="User Name"></asp:Label>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
<asp:Label ID="lblEMail" runat="server" Text="EMail"></asp:Label>
<asp:TextBox ID="EMail" runat="server"></asp:TextBox>
<asp:Label ID="lblPassword" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="Password" runat="server"></asp:TextBox>
<asp:Label ID="lblConfirmPassowrd" runat="server" Text="Confirm Password"></asp:Label>
<asp:TextBox ID="ConfirmPassowrd" Text="1234567" runat="server"></asp:TextBox>
<asp:Label ID="lblTitle" runat="server" Text="Title"></asp:Label>
<asp:TextBox ID="Title" Text="Title1234567" runat="server"></asp:TextBox>
<asp:PlaceHolder ID="Captcha" runat="server" />
</ContentTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="UserRegistrationStep_2" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
I placed the sample code in three different events:
protected void Page_Load(object sender, EventArgs e)
{
string s0 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Password")).Text;
string s1 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Title")).Text;
string s2 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text;
string s = s0+ s1 + s2;
}
protected void UserRegistration_Load(object sender, EventArgs e)
{
string s0 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Password")).Text;
string s1 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Title")).Text;
string s2 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text;
string s = s0 + s1 + s2;
}
protected void UserRegistration_PreRender(object sender, EventArgs e)
{
string s0 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Password")).Text;
string s1 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("Title")).Text;
string s2 = ((TextBox)UserRegistration.CreateUserStep.ContentTemplateContainer.FindControl("UserName")).Text;
string s = s0 + s1 + s2;
}
I am able to retrieve Title property in the Page_Load event, however UserName and Password returns an empty string in all three events. Why is this? How can I retrieve these values?
Try to get the same via OnCreatedUser event.