asp.net创建uzer向导,以自定义步骤获取控件的控件 [英] asp.net create uzer wizard getting a handle on controls in custom steps

查看:80
本文介绍了asp.net创建uzer向导,以自定义步骤获取控件的控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为乌兹别克斯坦增加了一个额外的步骤

I have added an extra step to my uzerwizard

<asp:TemplatedWizardStep id="stpPayment" runat="server" Title="Payment">
        <ContentTemplate>
<asp:DropDownList ID="cmbSubs" runat="server" ClientIDMode="Static" 
                            Width="200px">

                            <asp:ListItem Value="month">Monthly Subscription</asp:ListItem>
                            <asp:ListItem Value="year">Annual Subscription</asp:ListItem>
                        </asp:DropDownList>

我成功导航到新步骤

protected void NewUserprofileWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
    if (NewUserprofileWizard.ActiveStepIndex == 0)
    {
        NewUserprofileWizard.ActiveStepIndex = 1;

    }
}

但是我无法从我的代码后面访问下拉列表 注意:我可以在第一步(createuser)中找到控件的句柄.

but I cant get access to the dropdownlist from my codebehind note: i can get a handle onto the controls in the 1st (createuser) step.

,但是下一步中的所有控件始终返回null.

but any controls in the next step always return a null.

这是我正在使用的代码

DropDownList cmb = (DropDownList)NewUserprofileWizard.WizardSteps[1].FindControl("cmbSubs");

我总是返回null.

请注意,这很好用

TextBox tmp = (TextBox)NewUserprofileWizard.CreateUserStep.ContentTemplateContainer.FindControl("Email");
    userProfile.AccountEmail = tmp.Text;

问题似乎是自定义步骤所独有的

problem seems unique to custom steps

感谢您的帮助

尝试过Gregors建议.没运气.我的总是出现为空.

Tried Gregors suggestion. no luck. mine always comes up as null.

如果该帮助以下任何一项: 我的向导在用户控件内. 使用用户控件的页面在母版页中.....

if thsi helps any: my wizard is inside a user control.. the page that uses the user control is inside a master page.....

推荐答案

今天我的Google foo看起来好多了

it appears that today my google foo was doing much better

因为我在templatewizardstep中,所以我不得不将向导步骤投射到templatedwizardstep中.

because i am in a templateswizardstep, i have to cast the wizardstep into the templatedwizardstep.

从这里我现在可以找到控件.哇!

from here i can now find the control. whooohoo!

TemplatedWizardStep step = (TemplatedWizardStep)NewUserprofileWizard.WizardSteps[1];
cmb = (DropDownList)step.ContentTemplateContainer.FindControl("cmbSubs"); 

非常感谢您的帮助

这篇关于asp.net创建uzer向导,以自定义步骤获取控件的控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆