我想更多的字段添加到CreateUserWizardStep
,這裏是我補充說:爲什麼不能asp.net找到我的文本框?
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<table border="0">
<tr>
<td align="right">
<asp:Label ID="NickNameLabel" runat="server" AssociatedControlID="NickName">Nick Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="NickName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="NickName"
ErrorMessage="Nick Name is required." ToolTip="Nick Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<%-- The default code is left unchanged, but not shown here --%>
</table>
</ContentTemplate>
</asp:CreateUserWizardStep>
然後我試圖引用的對象這樣
protected void NewUserWizard_CreatedUser(object sender, EventArgs e)
{
CreateUserWizardStep step = NewUserWizard.FindControl("CreateUserWizardStep1") as CreateUserWizardStep;
TextBox nickName = step.FindControl("NickName") as TextBox;
// insert additional information to the database
}
的問題是,我獲得空值爲nickName
。我錯誤地使用了FindControl("")
嗎?
爲什麼不直接把它們稱爲this.NickName或this.CreateWizardSTep1? – n8wrl 2010-05-05 12:41:07