的FindControl属性的CreateUserWizard不工作 [英] Findcontrol property not working in createUserWizard
问题描述
我使用ASP的CreateUserWizard控件创建我的用户,我想添加一些额外的字段(用户额外的信息),我在我自己的表正在挽救。
我尝试访问code这些自定义的文本框后面的findContol财产(因为他们是里面的CreateUserWizard)
问题是,我声明并初始化作为控制,文本框为空。
以下是我如何做到这一点:
文本框t_desc =(文本框)(CreateUserWizard1.FindControl(txt_desc));
o.organisation_description = t_desc.Text;
这是控制是如何嵌套的:
< ASP:CreateUserWizard控件ID =CreateUserWizard1=服务器
oncreateduser =CreateUserWizard1_CreatedUser>
< WizardSteps>
< ASP:CreateUserWizardStep ID =CreateUserWizardStep1=服务器
标题=Registreer UW organisatie>
<&的ContentTemplate GT;
< DIV CLASS =行>
< DIV CLASS =半壁江山>
<表>
&所述; TR>
< TD ALIGN =右>
< ASP:标签ID =lbl_organisation_description=服务器AssociatedControlID =txt_desc> Beschrijf UW organisatie:LT; / ASP:标签>
< / TD>
&所述; TD>
< ASP:文本框ID =txt_desc=服务器的ValidationGroup =CreateUserWizard1>< / ASP:文本框>
< / TD>
< / TR>
< /表>
< / DIV>
< / DIV>
< /&的ContentTemplate GT;
< / ASP:CreateUserWizardStep>
< / WizardSteps>
< / ASP:&的CreateUserWizard GT;
CreateUserWizardStep步=(CreateUserWizardStep)CreateUserWizard1.FindControl(CreateUserWizardStep1);
如果(步骤!= NULL)
{
TXT文本框=(文本框)step.ContentTemplateContainer.FindControl(txt_desc);
}
或者如果你可以看到从服务器 - code你的脚步控制
TXT文本框=(文本框)CreateUserWizardStep1.ContentTemplateContainer.FindControl(txt_desc);
I'm using ASP's createUserWizard control to create my users, and I'd like to add some extra fields (with extra info on the user) which I'm saving in my own table.
I try to access these custom textboxes in code behind with the findContol property (since they're inside the createUserWizard)
The problem is that the textbox I declare and initialize as the control, is null. Here's how I do it:
TextBox t_desc = (TextBox)(CreateUserWizard1.FindControl("txt_desc"));
o.organisation_description = t_desc.Text;
And this is how the control is nested:
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
oncreateduser="CreateUserWizard1_CreatedUser">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server"
Title="Registreer uw organisatie">
<ContentTemplate>
<div class="row">
<div class="half">
<table>
<tr>
<td align="right">
<asp:Label ID="lbl_organisation_description" runat="server" AssociatedControlID="txt_desc">Beschrijf uw organisatie:</asp:Label>
</td>
<td>
<asp:TextBox ID="txt_desc" runat="server" ValidationGroup="CreateUserWizard1"></asp:TextBox>
</td>
</tr>
</table>
</div>
</div>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</asp:CreateUserWizard>
CreateUserWizardStep step = (CreateUserWizardStep) CreateUserWizard1.FindControl("CreateUserWizardStep1");
if (step!=null)
{
TextBox txt = (TextBox)step.ContentTemplateContainer.FindControl("txt_desc");
}
or if you can see your step control from server-code
TextBox txt = (TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txt_desc");
这篇关于的FindControl属性的CreateUserWizard不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!