Freelance Jobs

MultiView And View Server Control

Both MultiView and View Control work together and provided us the capability to make the particular section on and off. It's similiar to the visibility of panel control.

The Following Code for the Default.aspx Page [Source].

<form id="form1" runat="server">
<div>

<asp:MultiView ID="MultiView1" runat="server">
<asp:View ID="View1" runat="server">
<asp:BulletedList ID="BulletedList1" runat="server">
<asp:ListItem>Cricket</asp:ListItem>
<asp:ListItem>Football</asp:ListItem>
<asp:ListItem>Hockey</asp:ListItem>
<asp:ListItem>Carrom</asp:ListItem>
</asp:BulletedList>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click"
Text="Next View" />
</asp:View>
<asp:View ID="View2" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>India</asp:ListItem>
<asp:ListItem>America</asp:ListItem>
<asp:ListItem>Australia</asp:ListItem>
<asp:ListItem>New Zealand</asp:ListItem>
</asp:DropDownList>
<br />
<br />
<br />
<asp:Button ID="Button3" runat="server" onclick="Button3_Click"
Text="Previous View" />

<asp:Button ID="Button2" runat="server" onclick="Button2_Click"
Text="Next View" />
</asp:View>
<asp:View ID="View3" runat="server">
<asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="True"
onselectedindexchanged="CheckBoxList1_SelectedIndexChanged">
<asp:ListItem>Keyboard</asp:ListItem>
<asp:ListItem>Mouse</asp:ListItem>
<asp:ListItem>Monitor</asp:ListItem>
<asp:ListItem>Cabinet</asp:ListItem>
</asp:CheckBoxList>
<br />
<br />
<asp:Button ID="Button4" runat="server" onclick="Button4_Click"
Text="Previous View" />

</asp:View>
<br />
<br />
</asp:MultiView>
</div>

Write the following code for the Default.aspx.cs file


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
MultiView1.ActiveViewIndex = 0;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex += 1;
}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex += 1;

}
protected void Button3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex -= 1;
}
protected void Button4_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex -= 1;
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
Response.Write("Your Selected " + DropDownList1.SelectedValue);
}
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
String str ="";
for(int i=0;i {
if(CheckBoxList1.Items[i].Selected)
{
str += CheckBoxList1.Items[i].Text + ",";
}
}
if (str.Length > 0)
{
str = str.Substring(0, str.Length - 1);
Response.Write(str);
}
}
}

0 Comments:

Post a Comment



ONLINE JOBS