Home
 Index > ASP.NET Web Applications > How to Disable SideBar Links in the ASP.NET Wiz...

ASP.NET Web Applications:  Wizard

How to Disable SideBar Links in the ASP.NET Wizard Web Control

Create a SideBarTemplate for your Wizard to control the behavior of Sidebar steps.

Added on 20 Jul 2008

Scenarios:

Scenario Summary:
Allow users to view the wizard steps in the sidebar without allowing them to click on the links.
Scenario Details:
If all the pages of the Wizard must be completed, you probably don't want the user to be able to navigate from the first to the last step (skipping all the steps in between) and then submitting the form.  Therefore, you might simply wish to disable all the links and require the user to navigate with the navigation buttons.
Added on 20 Jul 2008

Solution Summary:
Create your own SideBarTemplate to gain access to the OnClientClick property of the SideBarButtons and set it to "return false".
Solution Details:
    <asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" 
        
BackColor="#F7F6F3" 
        
Font-Names="Verdana" CellPadding="10" Height="100%" Width="700px">
        <StepStyle BorderWidth="0px" ForeColor="#5D7B9D" />
        <NavigationStyle HorizontalAlign="Left" />
        <WizardSteps>
            <asp:WizardStep runat="server" Title="Step 1" StepType="Start">
                This is Step One<br />
            </asp:WizardStep>
            <!-- Add more steps here-->

            <!-- Create SideBarTemplate -->
        <SideBarTemplate>
        <asp:DataList ID="SideBarList" runat="server" OnItemDataBound="SideBarList_ItemDataBound">
          <ItemTemplate>
            <!-- Return false when linkbutton is clicked -->
             <asp:LinkButton  ID="SideBarButton" OnClientClick="return false" ForeColor="White" runat="server"></asp:LinkButton>
          </ItemTemplate>
          <SelectedItemStyle Font-Bold="true"/>
        </asp:DataList>
        </SideBarTemplate>
    </asp:Wizard>
Was this solution useful? Yes No Added on 20 Jul 2008
Rating: 

Scenario Summary:
Allow users to only click on previous steps, but not on those still to come.
Scenario Details:

If the user has reached step three and wishes to return to step one, he or she shouldn't need to click the previous button twice.  Links to all previous steps should be available to the user, while future steps remain disabled.

Added on 20 Jul 2008

Solution Summary:
Specify a SideBarTemplate with the required DataList and set the enabled state on ItemDataBound.
Solution Details:

ASPX:

        <SideBarTemplate>
            <asp:DataList ID="SideBarList" runat="server" OnItemDataBound="SideBarList_ItemDataBound">
              <ItemTemplate>
                 <asp:LinkButton  ID="SideBarButton" ForeColor="White" runat="server"></asp:LinkButton>
              </ItemTemplate>
              <SelectedItemStyle Font-Bold="true"/>
            </asp:DataList>
       </SideBarTemplate> 

ASPX.VB (Code-Behind):

    Public Sub SideBarList_ItemDataBound(ByVal sender As ObjectByVal e As DataListItemEventArgs)
        
Dim dataitem As WizardStep = CType(e.Item.DataItem, WizardStep)
        
Dim lnkBtn As LinkButton = CType(e.Item.FindControl("SideBarButton"), LinkButton)
        
If Not dataitem Is Nothing Then
            lnkBtn.Enabled = (e.Item.ItemIndex <= Wizard1.ActiveStepIndex)
        
End If
    End Sub
Was this solution useful? Yes No Added on 20 Jul 2008
Rating: 

Copyright 2012 © E-Centric, Inc. | Terms of Use