Multiview and View controls in ASP.NET(3.5)
The MultiView and View controls were introduced in Asp.Net (2.0).The Multiview acts like a standalone controls which helps in toggling between views. In a simpler way, it is a container that can hold various “VIEW” controls. And the “VIEW” control can hold any number of other controls, the benefit is they are grouped together, so that its easy to provide visibility.
Working (with an Eg:)
First drag and drop a multiview control into your page(MultiView1),now inside it place two views(View1,View2).Now inside both views write the names to distinguish.And place a button inside each view.The code below is the code section of the page(multivwDemo.aspx).The code is written in C-Sharp.The fact is there is nothing much to code.The only thing we need to do is to specify the index of the VIEW.The ViewIndex of “View”1 is 0 and of “View2” is 1.Rest you will understand by just checking the code.
“multivwDemo.aspx.cs”
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;public partial class multivwDemo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
}
Related Topics(Gridview Controls,FileUpload Control….)
Related posts:








Leave your response!