Asp.net Multiview & Wizard

Multi View& Wizard

 

Multi view usage

 

Aspx Code

 

<asp:MultiViewrunat="server" ID="mvTest"ActiveViewIndex="0">
            <asp:Viewrunat="server" ID="firstView">
                <span>step 1.</span>
            </asp:View>
            <asp:ViewID="secondView" runat="server" >
                <span>step 2.</span>
            </asp:View>
            <asp:ViewID="thirdView" runat="server">
                <span>step 3.</span>
            </asp:View>
            <asp:ViewID="forthView" runat="server">
               <span>finished.</span>
            </asp:View>
        </asp:MultiView>
        <div>
            <asp:Buttonrunat="server" ID="btnPre" CommandName="PrevView"Text="Back" OnClick="btnPre_Click"/>
            <asp:Button runat="server"ID="btnNext" Text="Next" CommandName="NextView"OnClick="btnNext_Click"/>
        </div>


 

Code behind

 

 

 

private void ShowViewBtn()
        {
            btnPre.Visible =mvTest.ActiveViewIndex > 0;
            btnNext.Visible =mvTest.ActiveViewIndex < mvTest.Views.Count - 1;
        }
 
        protected void btnPre_Click(objectsender, EventArgs e)
        {
           mvTest.SetActiveView(mvTest.Views[--mvTest.ActiveViewIndex]);
            ShowViewBtn();
        }
 
        protected void btnNext_Click(objectsender, EventArgs e)
        {
           mvTest.SetActiveView(mvTest.Views[++mvTest.ActiveViewIndex]);
            ShowViewBtn();
        }


 

Wizard usage

 

Aspx code :

 

<asp:WizardID="wizardTest" runat="server" Width="467px"BackColor="#EFF3FB" BorderColor="#B5C7DE"
        BorderWidth="1px"Height="500px" DisplayCancelButton="True"OnCancelButtonClick="wizardTest_Cancel"
       OnFinishButtonClick="wizardTest_Finished"OnActiveStepChanged="wizardTest_ActiveStepChanged"
        OnNextButtonClick="wizardTest_Next"OnPreviousButtonClick="wizardTest_Prev"OnSideBarButtonClick="wizardTest_SlideBtnClick">
        <WizardSteps>
            <asp:WizardStepID="WizardStep1" runat="server"Title="Personal">
                <h3>
                    Personal Profile</h3>
                Preferred Programming Language:
                <asp:DropDownListID="lstLanguage" runat="server">
                   <asp:ListItem>C#</asp:ListItem>
                   <asp:ListItem>VB</asp:ListItem>
                    <asp:ListItem>J#</asp:ListItem>
                   <asp:ListItem>Java</asp:ListItem>
                   <asp:ListItem>C++</asp:ListItem>
                   <asp:ListItem>C</asp:ListItem>
                </asp:DropDownList>
                <br />
            </asp:WizardStep>
            <asp:WizardStepID="WizardStep2" runat="server" Title="Company"AllowReturn="False">
                <h3>
                    Company Profile</h3>
                Number of Employees:
                <asp:TextBoxID="txtEmpCount" runat="server" />
                Number of Locations:
                <asp:TextBoxID="txtLocCount" runat="server" />
            </asp:WizardStep>
            <asp:WizardStepID="WizardStep3" runat="server"Title="Software">
                <h3>
                    Software Profile</h3>
                Licenses Required:
                <asp:CheckBoxListID="lstTools" runat="server">
                    <asp:ListItem>VisualStudio 2008</asp:ListItem>
                    <asp:ListItem>Office2007</asp:ListItem>
                    <asp:ListItem>WindowsServer 2008</asp:ListItem>
                    <asp:ListItem>SQLServer 2008</asp:ListItem>
                </asp:CheckBoxList>
            </asp:WizardStep>
            <asp:WizardStepID="Complete" runat="server" Title="Complete">
                <br />
                Thank you for completing thissurvey.<br />
                Your products will be deliveredshortly.<br />
            </asp:WizardStep>
        </WizardSteps>
       
 
        <StartNavigationTemplate>
           <i>StartNavigationTemplate</i><br />
            <asp:ButtonID="StartNextButton" runat="server"Font-Size="35" Text="Start"CommandName="MoveNext" />
        </StartNavigationTemplate>
        <StepNavigationTemplate>
           <i>StepNavigationTemplate</i><br />
            <asp:ButtonID="StepPreviousButton" runat="server"CausesValidation="False" CommandName="MovePrevious"
                Text="Previous" />
            <asp:ButtonID="StepNextButton" runat="server" Text="Next"CommandName="MoveNext" />
        </StepNavigationTemplate>
 
        <FinishNavigationTemplate>
           <i>FinishNavigationTemplate</i><br />
            <asp:ButtonID="FinishPreviousButton" runat="server" CausesValidation="False"Text="Previous"
               CommandName="MovePrevious" />
            <asp:ButtonID="FinishButton" Font-Size="35" runat="server"Text="Finish" CommandName="MoveComplete" />
        </FinishNavigationTemplate>
       
 
</asp:Wizard>


 

Templates:

·        HeaderTemplate  Defines the content of the header region

·        SideBarTemplate  Defines the sidebar, which typically includes navigation links for each Step

·        StartNavigationTemplate  Defines the navigation buttons for the first step (when Step Type is Start)

·        StepNavigationTemplate  Defines the navigation buttons for intermediate steps (when  StepType  is Step)

·        FinishNavigationTemplate  Defines the navigation buttons for the final step (when StepType is Finish)

·        LayoutTemplate  Defines the overall arrangement of the header, sidebar, step area, and Navigation buttons.

 

 

Styles can set :

 

Header Style

Sidebar style

Sidebar button style

Step style

Navigation style

Navigation button style

Start next button style

Step next button style

Step previous buttonstyle

Finish previous buttonstyle

Cancel button style 



你可能感兴趣的:(Asp.net Multiview & Wizard)