ASP.Net メンバーシップと CreateUserWizard を使用して、コードでパスワード、ユーザー名、確認パスワードなどの値を取得できないことに気付きました。拡張拡張プロパティを取得できます。
UserName などを取得できるかどうか疑問に思っています。以下にサンプル コードを含めます。フィールドに入力してポストバックすると、Password、ConfirmPassword、Email、および UserName を参照できますが、受け取った値は空の文字列です。Title フィールドが空の文字列を返さないTitle フィールドの値に到達できます。以下のコードはサブセットにすぎません。
<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>
サンプル コードを 3 つの異なるイベントに配置しました。
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 プロパティを取得できますが、UserName と Password は 3 つのイベントすべてで空の文字列を返します。どうしてこれなの?これらの値を取得するにはどうすればよいですか?