在向导控件中隐藏asp.net中后面代码的下一个按钮

时间:2011-03-16 07:15:31

标签: c# asp.net animation wizard

我有一个带有向导控件的asp.net页面。我想在管理员登录以外的时候显示错误的下一个按钮(比如经销商,子经销商登录)。如何使其隐藏或更改其文本?我试过这一行让它变得可见:

  
    

((Button)Wizard1.FindControl(“StepNavigationTemplateContainerID”)。FindControl(“StepNextButton”))。Visible = false;

  

HTML是:

   <asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="False" Width="90%" StepPreviousButtonText=""
            StepPreviousButtonType="Image" 
            onfinishbuttonclick="Wizard1_FinishButtonClick" 
            onnextbuttonclick="Wizard1_NextButtonClick">
            <NavigationStyle HorizontalAlign="Left"  />
            <WizardSteps>
                <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
                     //Some design 
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 1">
                     //Some design
                </asp:WizardStep>
            </WizardSteps>

            <StartNavigationTemplate>
                <asp:Button ID="StepNextButton" runat="server" CommandName="MoveNext"    

                Text="Next" />
            </StartNavigationTemplate>
      <FinishNavigationTemplate>
            <asp:Button ID="FinishButton" runat="server" CommandName="MoveComplete" Text="Finish" />
        </FinishNavigationTemplate>
    </asp:Wizard>

但听起来没什么。我该怎么办?

2 个答案:

答案 0 :(得分:6)

试试这个......

((Button)Wizard1.FindControl("StartNavigationTemplateContainerID").FindControl("StepNextButton")).Visible = false;

我已将StepNavigationTemplateContainerID替换为StartNavigationTemplateContainerID,因为您需要从Start Naveigation中找到

答案 1 :(得分:1)

如果您要删除 StartNextButton ,只需将StartNextButtonType设置为“链接”,将StartNextButtonText设置为空。这应该是最简单的方法