In this tutorial, I will show you how to use MultiView in an ASP.NET. Using C#, and we will take straightforward example of the same student information, which we used in our Wizard control and it will be the same design which we will integrate here.
INITIAL CHAMBER
Step 1
Open Your Visual Studio 2010 and create an empty Website, give a suitable name [view_demo].
Step 2
In Solution Explorer, you get your empty Website, add a Web form.
For Web Form
view_demo (Your Empty Website) -> Right click -> Add New Item -> Web Form. Name it as ->view_demo.aspx.
DESIGN CHAMBER
Step 3
Open your view_demo.aspx, drag and drop Multiview control from the toolbox. Inside your Multiview, add three Views as – Student Details, Student Course Details, Student Personal Details and Student Summary. Design your .aspx file, as shown below.
Your Design will look like this,
CODE CHAMBER
Step 5
Here, we will code for our design. We had assumed that in the initial phase after entering the student details, on the next button; the student should come to the student course detail view and on the next button; the student should move to Student Persona Detail.
In each View, we had taken Next and Previous buttons, so that the user can go back and forth, while filling up the form. This back and forth movement can be done with the help of one of the properties of Multiview – ActionViewIndex.
ActioViewIndex is used to get an Index of your View. For a very first View, the Index would be = 0. If you want to move to Next View , then the index would be = 1. If you want to move back, then View index would be again = 0, A very similar thing was done in our code too.
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
-
- public partial class Multiview : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- MultiView1.ActiveViewIndex = 0;
- }
-
- }
-
- protected void Button2_Click(object sender, EventArgs e)
- {
- MultiView1.ActiveViewIndex = 1;
- }
-
- protected void Button3_Click(object sender, EventArgs e)
- {
- MultiView1.ActiveViewIndex = 0;
- }
-
- protected void Button4_Click(object sender, EventArgs e)
- {
- MultiView1.ActiveViewIndex = 2;
- }
-
- protected void Button5_Click(object sender, EventArgs e)
- {
- MultiView1.ActiveViewIndex = 1;
-
- }
-
- protected void Button6_Click(object sender, EventArgs e)
- {
- MultiView1.ActiveViewIndex = 3;
-
- Label1.Text = TextBox1.Text;
- Label2.Text = TextBox2.Text;
- Label3.Text = TextBox3.Text;
- Label4.Text = TextBox4.Text;
- Label5.Text = TextBox5.Text;
- Label6.Text = TextBox6.Text;
- Label7.Text = TextBox7.Text;
- }
- }
Output
In the output, we will first view Student Details, where we fill up the details and press Next to move to Next View.
Student Details
Student Course Details
Student Personal Details
Student Summary
Also, in the last View, you can put one more button as a Finish button and can save the data in the database.
Thank you for reading. Hope, you liked it. Have a good day.