In this article you will learn about MultiView control and View control.
- Defination / Introduction
- Step by step implemation.
- Difference between MultiView Control vs Wizard control
Definition / Introduction
Multiview and View are both server controls. Multiview control and View control are used together. Multiview is parent control for View control. As the name defines itself, Multiview control is used to control various type of views.
Multiview contro was introduced in .Net Framework version 2.0.
Inside View control we are usin the rest of server controls. Viewis operated through MultiView1.ActiveViewIndex, and this property will display appropriate view as per the indexed numbers of view. If no view is active index will return -1 and as usual index value starts from 0.
Multiview control helps to display or render the particular view on the page.
This can be used for Survey, E-Commerce and Data entry Forms as per your requirement.
- Prefix for MultiView control is mv
- Prefix for View control is v
MultiView control
- <asp:MultView ID= "mvEntryForm" runat= "server">
- <%--[View control codes come inside of MultiView]--%>
- </asp:MultiView>
View Control - <asp:View ID= "vAddressDetail" runat= "server">
- </asp:View>
Note
View control is used inside of MultiView contro and looks like this way:
- <asp:MultView ID= "mvEntryForm" runat= "server">
- <asp:View ID= "vAddressDetail" runat= "server"> </asp:View>
- </asp:MultiView>
MultiView Control and Wizard Control difference between
Multiview control and wizard control are more or lessthe same but one major difference between them is the rich user interface in wizard control. Wizard control has side bar and Next, Previous and Finish buttons. A side bar is included to navigate among the various steps in the Wizard control.
For information on Multiview control visit following
link.
Logic of Implementation / Implementation's Scenario
Friend Data Entry Form
We will implement MultiView/View control on Friend Data Entry Screen where we accept following detail in different – different views. Here we have used the following 4 (Four) views:
- Address Detail
- Contact Detail
- Education Detail
- Preview and Submit Detail
To implement a MultiView and View we had used the following things:
- Create a ASP.NET Empty Website project named: MultiViewAndView.
- Add new WebForm named : Default.aspx.
Right click on solution explorer, Select Add --> Add New Item --> Insert a New WebForm.
UI Explaination
Total four views:
- Address Detail
- Contact Detail
- Education Detail
- Preview and Submit Detail
Here, you can see dropdown list where you can switch the view.
Address View
Contact Detail
Education Detail
Preview and Submit
Default.aspx code
Default.aspx.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
-
- public partial class _Default : System.Web.UI.Page
- {
-
- protected void Page_Load(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = 0;
- }
-
-
-
- protected void btnNextContactDetail_Click(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = 1;
-
- }
- protected void btnPrevAddressDetail_Click(object sender, EventArgs e)
- {
-
- }
- protected void btnNextEducationDetail_Click(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = 2;
- }
- protected void btnPrevContactDetail_Click(object sender, EventArgs e)
- {
-
- }
- protected void btnNextPreviewAndSubmit_Click(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = 3;
- lblSummary.Text = "Hello, " + txtName.Text.ToUpper() + "<br><br> <p style=" + "\"font-size:12px\"" + ">Please, Check your detail and submit.</p>";
- lblAddressDetail.Text = txtAddress.Text;
- lblContactDetail.Text = "Mobile Number : " + txtMobile.Text + "<br>" + "Email ID : " + txtEmailID.Text;
- lblEducationDetail.Text = txtEducation.Text;
-
- }
- protected void ddlDetail_SelectedIndexChanged(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = Convert.ToInt16(ddlDetail.SelectedValue);
-
- }
- protected void btnEducationDetail_Click(object sender, EventArgs e)
- {
- mvEntryForm.ActiveViewIndex = 2;
- }
- }