Hi,
I am using ASP.Net Menu Site map path. I have created menu using site map path and it is highlighting selected menu works perfectly in local machine.
But, the same code when i hosted in server the selected highlighting menu will not appear.
pls. give suggestion...below is my code.
MainVb.master
<%@ Master Language="VB" CodeFile="MainVB.master.vb" Inherits="MainVB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.main_menu
{
width: 100px;
background-color: #8AE0F2;
color: #000;
text-align: center;
height: 30px;
line-height: 30px;
margin-right: 5px;
}
.level_menu
{
width: 110px;
background-color: #000;
color: #fff;
text-align: center;
height: 30px;
line-height: 30px;
margin-top: 5px;
}
.selected
{
background-color: #852B91;
color: #fff;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<asp:Menu ID="Menu" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal"
OnMenuItemDataBound="OnMenuItemDataBound">
<LevelMenuItemStyles>
<asp:MenuItemStyle CssClass="main_menu" />
<asp:MenuItemStyle CssClass="level_menu" />
</LevelMenuItemStyles>
</asp:Menu>
<hr />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
Mainvb.master.vb
Partial Class MainVB
Inherits System.Web.UI.MasterPage
Protected Sub OnMenuItemDataBound(sender As Object, e As MenuEventArgs)
If SiteMap.CurrentNode IsNot Nothing Then
If e.Item.Text = SiteMap.CurrentNode.Title Then
If e.Item.Parent IsNot Nothing Then
e.Item.Parent.Selected = True
Else
e.Item.Selected = True
End If
End If
End If
End Sub
End Class
web.sitemap
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="Home" description="">
<siteMapNode url="Home.aspx" title="Home" description="Home Page" />
<siteMapNode url="javascript:;" title="Services" description="Services Page">
<siteMapNode url ="Consulting.aspx" title="Consulting" description="Consulting Page"></siteMapNode>
<siteMapNode url ="Outsourcing.aspx" title="Outsourcing" description="Outsourcing Page"></siteMapNode>
</siteMapNode>
<siteMapNode url="About.aspx" title="About" description="About Us Page" />
<siteMapNode url="Contact.aspx" title="Contact" description="Contact Us Page" />
</siteMapNode>
</siteMap>
What I have tried:
i have tried the below code in server.
MainVb.master
<%@ Master Language="VB" CodeFile="MainVB.master.vb" Inherits="MainVB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<asp:ContentPlaceHolder ID="head" runat="server">
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
.main_menu
{
width: 100px;
background-color: #8AE0F2;
color: #000;
text-align: center;
height: 30px;
line-height: 30px;
margin-right: 5px;
}
.level_menu
{
width: 110px;
background-color: #000;
color: #fff;
text-align: center;
height: 30px;
line-height: 30px;
margin-top: 5px;
}
.selected
{
background-color: #852B91;
color: #fff;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
<asp:Menu ID="Menu" runat="server" DataSourceID="SiteMapDataSource1" Orientation="Horizontal"
OnMenuItemDataBound="OnMenuItemDataBound">
<levelmenuitemstyles>
<asp:MenuItemStyle CssClass="main_menu" />
<asp:MenuItemStyle CssClass="level_menu" />
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</form>
</body>
</html>
Mainvb.master.vb
Partial Class MainVB
Inherits System.Web.UI.MasterPage
Protected Sub OnMenuItemDataBound(sender As Object, e As MenuEventArgs)
If SiteMap.CurrentNode IsNot Nothing Then
If e.Item.Text = SiteMap.CurrentNode.Title Then
If e.Item.Parent IsNot Nothing Then
e.Item.Parent.Selected = True
Else
e.Item.Selected = True
End If
End If
End If
End Sub
End Class
web.sitemap
<sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
<sitemapnode url="" title="Home" description="">
<sitemapnode url="Home.aspx" title="Home" description="Home Page">
<sitemapnode url="javascript:;" title="Services" description="Services Page">
<sitemapnode url="Consulting.aspx" title="Consulting" description="Consulting Page">
<sitemapnode url="Outsourcing.aspx" title="Outsourcing" description="Outsourcing Page">
<sitemapnode url="About.aspx" title="About" description="About Us Page">
<sitemapnode url="Contact.aspx" title="Contact" description="Contact Us Page">