2

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) ステップでコントロールのハンドルを取得できます。

ただし、次のステップのコントロールは常に null を返します。

これは私が使用しているコードです

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

私は常にヌルを返します。

これはうまく機能することに注意してください

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

問題はカスタムステップに固有のようです

助けてくれてありがとう


Gregors の提案を試しました。運がない。私は常にnullとして表示されます。

ここに画像の説明を入力

これが役立つ場合:私のウィザードはユーザーコントロール内にあります..ユーザーコントロールを使用するページはマスターページ内にあります.....

4

2 に答える 2

1

以下は、私が作成した小さなサンプルです。最初の aspx コードです。

        <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnNextButtonClick="CreateUserWizard1_NextButtonClick">
            <WizardSteps>
                <asp:WizardStep runat="server" Title="My Custom Step">
                    <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>
                </asp:WizardStep>
                <asp:CreateUserWizardStep runat="server" />
                <asp:CompleteWizardStep runat="server" />
            </WizardSteps>
        </asp:CreateUserWizard>

そして今、最初のドロップダウンを見つけるためのコード:

    protected void CreateUserWizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (e.CurrentStepIndex == 0)
        {
            //get instance to dropdown...
            string selectedValue = null;
            string controlId = null;
            foreach (var item in CreateUserWizard1.WizardSteps[0].Controls)
            {
                DropDownList ddl = item as DropDownList;
                if (ddl != null)
                {
                    selectedValue = ddl.SelectedValue;
                    controlId = ddl.ClientID;
                    break;
                }
            }       
        }
    }

もちろん、次のようにドロップダウンを見つけることもできます。

DropDownList cmbSubs = CreateUserWizard1.WizardSteps[0].FindControl("cmbSubs") as DropDownList;

ハッピーコーディング!

于 2013-03-14T21:30:18.860 に答える
0

今日、私のGoogle fooははるかにうまくいっているようです

私はテンプレートウィザードステップにいるので、ウィザードステップをテンプレートウィザードステップにキャストする必要があります。

ここから、コントロールを見つけることができます。フーフー!

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

助けてくれてありがとう

于 2013-03-20T10:51:50.637 に答える