19.3使用Menu控件

使用Menu控件

1、声明式添加Menu条目

MenuHyperLink.aspx
<%@ Page Language="C#" %>

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

</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Menu ID="Menu1" runat="server">
            <Items>
                <asp:MenuItem Text="Products" NavigateUrl="~/Products.aspx" />
                <asp:MenuItem Text="Services" NavigateUrl="~/Services.aspx">
                    <asp:MenuItem Text="Training" NavigateUrl="~/Training.aspx" />
                    <asp:MenuItem Text="Consulting" NavigateUrl="~/Consulting.aspx" />
                </asp:MenuItem>
            </Items>
        </asp:Menu>
    </div>
    </form>
</body>
</html>

显示:

总体感觉还不错。

MenuButtonLink.aspx
<%@ Page Language="C#" %>

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

    protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
    {
        lblMessage.Text = "You selected " + Menu1.SelectedValue;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Menu ID="Menu1" runat="server" OnMenuItemClick="Menu1_MenuItemClick">
            <Items>
                <asp:MenuItem Text="Products Page" Value="Products" />
                <asp:MenuItem Text="Services Page" Value="Services">
                    <asp:MenuItem Text="Training Page" Value="Training" />
                    <asp:MenuItem Text="Consulting Page" Value="Consulting" />
                </asp:MenuItem>
            </Items>
        </asp:Menu>
        <hr />
        <asp:Label ID="lblMessage" EnableViewState="false" runat="server" />
    </div>
    </form>
</body>
</html>

2011-5-18 15:58 danny
2、组合使用Menu控件和MultiView控件
P  -P695

你可能感兴趣的:(html,C++,c,XHTML,C#)