aspx页面代码
1<form id="form1" runat="server">
2 <div>
3 <asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
4 <Items>
5 <asp:MenuItem Text="<div style='width:150px; height:21px; background-image:url(Images/select.gif); text-align:center;'>Go</div>" Value="0">
6 </asp:MenuItem>
7 <asp:MenuItem Text="<div style='width:150px; height:21px; background-image:url(Images/unselect.gif); text-align:center;'>Return</div>" Value="1">
8 </asp:MenuItem>
9 </Items>
10 </asp:Menu>
11
12 <asp:MultiView ID="MultiView1" runat="server">
13 <asp:View ID="View1" runat="server">
14 view 1<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></asp:View>
15 <asp:View ID="View2" runat="server">
16 view 2<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></asp:View>
17 </asp:MultiView>
18 <br />
19 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
20 </form>
2 <div>
3 <asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal" StaticEnableDefaultPopOutImage="False">
4 <Items>
5 <asp:MenuItem Text="<div style='width:150px; height:21px; background-image:url(Images/select.gif); text-align:center;'>Go</div>" Value="0">
6 </asp:MenuItem>
7 <asp:MenuItem Text="<div style='width:150px; height:21px; background-image:url(Images/unselect.gif); text-align:center;'>Return</div>" Value="1">
8 </asp:MenuItem>
9 </Items>
10 </asp:Menu>
11
12 <asp:MultiView ID="MultiView1" runat="server">
13 <asp:View ID="View1" runat="server">
14 view 1<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></asp:View>
15 <asp:View ID="View2" runat="server">
16 view 2<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></asp:View>
17 </asp:MultiView>
18 <br />
19 <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
20 </form>
cs代码:
1protected void Page_Load(object sender, EventArgs e)
2 {
3 this.MultiView1.ActiveViewIndex = 0;
4 }
5
6 protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
7 {
8 int index = int.Parse(e.Item.Value);
9
10 this.MultiView1.ActiveViewIndex = index;
11
12 for (int i = 0; i < this.Menu1.Items.Count; i++)
13 {
14 if (i == int.Parse(e.Item.Value))
15 {
16 this.Menu1.Items[i].Text = this.Menu1.Items[i].Text.Replace("/unselect.gif", "/select.gif");
17 }
18 else
19 {
20 //this.Menu1.Items[i].ImageUrl = "Images/unselect.gif";
21 this.Menu1.Items[i].Text = this.Menu1.Items[i].Text.Replace("/select.gif", "/unselect.gif");
22 }
23 }
24 }
25
26 protected void Button1_Click(object sender, EventArgs e)
27 {
28 Response.Write(string.Format("value of view1 is : {0}<br>value of view 2 is {1}", this.TextBox1.Text, this.TextBox2.Text));
29 }
2 {
3 this.MultiView1.ActiveViewIndex = 0;
4 }
5
6 protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
7 {
8 int index = int.Parse(e.Item.Value);
9
10 this.MultiView1.ActiveViewIndex = index;
11
12 for (int i = 0; i < this.Menu1.Items.Count; i++)
13 {
14 if (i == int.Parse(e.Item.Value))
15 {
16 this.Menu1.Items[i].Text = this.Menu1.Items[i].Text.Replace("/unselect.gif", "/select.gif");
17 }
18 else
19 {
20 //this.Menu1.Items[i].ImageUrl = "Images/unselect.gif";
21 this.Menu1.Items[i].Text = this.Menu1.Items[i].Text.Replace("/select.gif", "/unselect.gif");
22 }
23 }
24 }
25
26 protected void Button1_Click(object sender, EventArgs e)
27 {
28 Response.Write(string.Format("value of view1 is : {0}<br>value of view 2 is {1}", this.TextBox1.Text, this.TextBox2.Text));
29 }
这里用的是Div里面显示文字,背景用图片显示,也可以直接用图片显示的