C#:如何在向导下一步之前检查字段的值?(下一步按钮单击)

本文关键字:下一步 单击 按钮 字段 向导 检查 | 更新日期: 2023-09-27 18:34:56

当用户在向导的第一步后单击"继续"时,我想检查MyRadioBtn的值(所选索引(是否为1。如果没有,则打开一个面板,不要继续执行向导的步骤 2。

我遇到的问题是"MyRadioBtn.SelectedIndex"条件从不返回值 1。

前端:

<asp:RadioButtonList ID="MyRadioBtn" runat="server" AutoPostBack="True">
     <asp:ListItem Value="0">No</asp:ListItem>
     <asp:ListItem Value="1">Yes</asp:ListItem>
</asp:RadioButtonList>

代码隐藏:

protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
    if (Wizard1.ActiveStepIndex == 0)
    {
        if (MyRadioBtn.SelectedIndex == 1)
        {
            //Stop the user from moving on to step 2
            e.Cancel = true;
            //Show the user a panel
            WarningPanel.Visible = true;
        }
        else {
           //Continue to STEP 2
        }
    }
}

C#:如何在向导下一步之前检查字段的值?(下一步按钮单击)

用户从 de DropDownList 中选择项目后,是否需要触发 postbkack?如果没有,请将AutoPostBack="True"更改为AutoPostBack="False"