我在<asp:CreateUserWizard \> --> <WizardSteps> --> <asp:CreateUserWizardStep\> --> <ContentTemplate>
此TextBox ID是UserName。
我正面临着推入这个TextBox的问题。当我做UserName.Text = "some name";
我收到此错误:“当前上下文中不存在名称'UserName'”
任何帮助?
thankes
protected void Page_Load(object sender, EventArgs e)
{
if (Session["VolunteerSessionList"] != null) // test if exists
{
UserName.Text = "some name";
}
答案 0 :(得分:0)
我只是假设ASPX将如下所示。如果是这样,您可以访问UserName
文本框,例如 - RegisterUser.UserName = "test"
protected void Page_Load(object sender, EventArgs e)
{
if (Session["VolunteerSessionList"] != null)
{
RegisterUser.UserName = "test";
}
}
<asp:CreateUserWizard ID="RegisterUser" runat="server" ...>
<LayoutTemplate>
....
</LayoutTemplate>
<WizardSteps>
<asp:CreateUserWizardStep ID="RegisterUserWizardStep" runat="server">
<ContentTemplate>
....
<asp:TextBox ID="UserName" runat="server" />
....
</ContentTemplate>
<CustomNavigationTemplate>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>