【问题标题】:Change functionality of next button in asp.net wizard在 asp.net 向导中更改下一个按钮的功能
【发布时间】:2014-01-14 08:14:58
【问题描述】:

我有一个由四个步骤组成的 ASP 向导,

  1. 添加客户 ID

  2. 添加项目 ID。

  3. 添加位置。

  4. 完成

我不希望用户在没有输入 ID 的情况下继续下一步并跳过任何步骤。 我已经尝试了所有事件并进行了很多搜索,但下一个和上一个按钮按原样工作。

我也想完成可点击侧边栏超链接的选项。

    if (e.CurrentStepIndex == 1)
    {
        if (LabelCustomerNotify.Text == "notset")
        {
            LabelCustomerNotify.Text = "You can not proceed without selecting customer id";
            Wizard1.ActiveStepIndex = 1;
        }
        else
        {

            Wizard1.ActiveStepIndex++;
        }
    }
    else if (e.CurrentStepIndex == 2)
    {
        if (LabelItemNotify.Text == "notset")
        {
            LabelItemNotify.Text = "You can not proceed without selecting Item id";
            Wizard1.ActiveStepIndex = 1;
        }
        else
        {

            Wizard1.ActiveStepIndex++;
        }
    }
    else if (e.CurrentStepIndex == 3)
    {

        Wizard1.ActiveStepIndex++;
    }

我已在 Wizard1_ActiveStepChanged、Wizard1_NextButtonClick 等事件中输入此代码

请帮帮我

【问题讨论】:

    标签: asp.net visual-studio-2010 wizard


    【解决方案1】:

    使用WizardNavigationEventArgs.Cancel 属性取消移动到下一步(在NextButtonClick 事件中),而不是您当前的方法:

    if (e.CurrentStepIndex == 1)
    {
        if (LabelCustomerNotify.Text == "notset")
        {
            LabelCustomerNotify.Text = "You can not proceed without selecting customer id";
            e.Cancel = true;
        }
    }
    

    如果它仍然无法正常工作,我会运行一个调试器并确保您的代码实际上正在进入该 if 块。您可能只是对这种情况有疑问。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-21
      • 1970-01-01
      • 2015-10-30
      • 1970-01-01
      相关资源
      最近更新 更多