How to create menu in asp.net ?

Ranjeet_8
Posted by Ranjeet_8 under ASP.NET category on | Points: 40 | Views : 1384
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
lblmsg.Text = Menu1.SelectedValue;
}


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="head1" runat="server">
<style type="text/css">
.menu
{
color: #000000;
border: Solid 1px Gray;
background-color: #C5C5C5;
padding: 2px 5px;
}
</style>
<title>ASP.Net Menu</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Menu ID="Menu1" OnMenuItemClick="Menu1_MenuItemClick" Orientation="Horizontal"
StaticMenuItemStyle-CssClass="menu" DynamicMenuItemStyle-CssClass="menu" runat="server">
<Items>
<asp:MenuItem Text="Colors">
<asp:MenuItem Text="Red" />
<asp:MenuItem Text="Blue" />
<asp:MenuItem Text="Green" />
</asp:MenuItem>
<asp:MenuItem Text="Products">
<asp:MenuItem Text="Products_Details">
<asp:MenuItem Text="Sub_Products1" />
<asp:MenuItem Text="Sub_Products2" />
</asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
<hr />
<asp:Label ID="lblmsg" EnableViewState="false" runat="server" />
</div>
</form>
</body>
</html>

Comments or Responses

Login to post response