您的位置:首页 > 运维架构

MultiView结合DropDownList实现选项卡功能

2008-01-12 16:13 302 查看
View 控件是一组控件的容器。View 控件必须始终包含在 MultiView 控件中。在 View 控件中,一次只能将一个 MultiView 控件定义为活动视图。ctiveViewIndex 属性指定 MultiView 控件的 Views 集合中的活动 View 控件。只要包含 MultiView 控件是可见的,活动视图控件就会呈现给客户端。使用 Visible 属性确定 View 控件及其子控件在页面上是否可见,以及是否呈现给客户端。View 控件可以包含任何类型的控件,包括其他 MultiView 控件。View 控件不支持任何样式属性。若要对 View 控件应用样式,请将一个或多个 Panel 控件添加到 View 控件中。

1

<%@ Page Language="C#" %>
2

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3

<script runat="server">
4


5

protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
6





{
7

MultiView1.ActiveViewIndex = Convert.ToInt32(DropDownList1.SelectedValue);
8

}
9


10

</script>
11

<html xmlns="http://www.w3.org/1999/xhtml">
12

<head id="Head1" runat="server">
13

<title>Untitled Page</title>
14

</head>
15

<body>
16

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

<div>
18

<h3>
19

<font face="Verdana">测试一下吧Multiview结合DropDownList实现选项卡功能</font>
20

</h3>
21

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
22

<asp:ListItem Value="0">View 1</asp:ListItem>
23

<asp:ListItem Value="1">View 2</asp:ListItem>
24

<asp:ListItem Value="2">View 3</asp:ListItem>
25

</asp:DropDownList><br />
26

<hr />
27

<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
28

<asp:View ID="View1" runat="server">
29

Now showing View #1<br />
30

<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><strong> </strong>
31

<asp:Button ID="Button1" runat="server" Text="Button" /></asp:View>
32

<asp:View ID="View2" runat="server">
33

Now showing View #2<br />
34

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="http://codeshark.cnblogs.com/">我的博客园</asp:HyperLink>
35

<asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl="http://blog.csdn.net/codeshark/">我的CSDN</asp:HyperLink></asp:View>
36

<asp:View ID="View3" runat="server">
37

Now showing View #3<br />
38

<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
39

</asp:View>
40

</asp:MultiView></div>
41

</form>
42

</body>
43

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: