0
使用ASP.Net成員和CreateUserWizard,我注意到我無法在代碼中檢索Passoword,UserName,ConfirmPassword等的值。我能夠重新獲取擴展的擴展屬性。ASP.Net C#CreateUserWizard用戶名,密碼屬性
想知道如果可能檢索用戶名等。我已經包括下面的示例代碼。當字段填充和回發時,我可以引用密碼,ConfirmPassword,電子郵件和用戶名,但收到的值是空字符串。我能夠達到標題字段的值,其標題字段不是返回空字符串。下面的代碼只是一個子集。
<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>
我把示例代碼在三個不同的事件:
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;
}
我能夠在Page_Load事件來檢索Title屬性,但是用戶名和密碼這三個事件,返回一個空字符串。爲什麼是這樣?我如何檢索這些值?