Category Archives: SiteMapDataSource

SiteMapDataSource

[RESOLVED]Navigation Treeview: how to open nested (not collapsed)

Hi,

I would like to change the treeview to open "nested" instead of all collapsed by default.

I’m using a sitemap as the datasource for my treeview.

When I preview the page the entire treeview is collapsed (and it is very long). I would prefer to see the parent nodes only by default and only when clicking on the parent, the child nodes collapse respectively.

How can I do that?

The code is:

<div
id="left_col">
<asp:TreeView ID="TreeView1" runat="server" DataSourceID="SiteMapDataSource1" Height="755px" ImageSet="Arrows" Width="16px">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" />
<NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD" HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>
<asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />
</div>

Hi Nebulosa,

Based on your description, my understanding is that you would like to set the child treeview node to collapsed as default.

If so, you can try to use the ExpandDepth property of TreeView control, when you set the value as "0", the treeview will only display the parent node.

More information about the ExpandDepth please refer to:
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.treeview.expanddepth(v=vs.110).aspx

Hope it helps.

Best Regards,
Terry Guo

[RESOLVED]help me fix eror web.config when i add sitemap

please help me, thanks!

code in web.config:

<system.web>
    <!–
            Set compilation debug="true" to insert debugging
            symbols into the compiled page. Because this
            affects performance, set this value to true only
            during development.
        –>
        <compilation debug="true"/>
        <!–
            The <authentication> section enables configuration
            of the security authentication mode used by
            ASP.NET to identify an incoming user.
        –>
        <authentication mode="Windows"/>
        <!–
            The <customErrors> section enables configuration
            of what to do if/when an unhandled error occurs
            during the execution of a request. Specifically,
            it enables developers to configure html error pages
            to be displayed in place of a error stack trace.

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
            <error statusCode="403" redirect="NoAccess.htm" />
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>
        –>
    <siteMap defaultProvider="Menu">
      <provider>
        <add name="Menu" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Menu.sitemap"/>
      </provider>
    </siteMap>

  </system.web>

 

eror when i run web on localhost :

Server Error in ‘/abc’ Application.


Configuration Error

Description:
An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Unrecognized element ‘provider’.

Source Error:

Line 38:         -->
Line 39:     <siteMap defaultProvider="Menu">
Line 40:       <provider> Line 41:         <add name="Menu" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Menu.sitemap"/>
Line 42:       </provider>


Source File: C:UsersAppleDesktopNew folderdaivietweb.config Line:
40


Version Information: Microsoft .NET Framework Version:2.0.50727.4971; ASP.NET Version:2.0.50727.4955

Hi,

You have mentioned Provider inside your sitemap node, which is not a valid node. You should mentioned it as ‘Providers‘.

Please change your code like given below

<siteMap defaultProvider="Menu">
      <providers>
        <add name="Menu" type="System.Web.XmlSiteMapProvider" siteMapFile="~/Menu.sitemap"/>
      </providers>
    </siteMap>

thanks! friend

but when i use it

Server Error in ‘/abc’ Application.


The file /daiviet/menu.sitemap required by XmlSiteMapProvider does not exist.

Description:
An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: The file /daiviet/menu.sitemap required by XmlSiteMapProvider does not exist.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:

[InvalidOperationException: The file /daiviet/menu.sitemap required by XmlSiteMapProvider does not exist.]
   System.Web.XmlSiteMapProvider.CheckSiteMapFileExists() +153
   System.Web.XmlSiteMapProvider.GetConfigDocument() +596
   System.Web.XmlSiteMapProvider.BuildSiteMap() +231
   System.Web.XmlSiteMapProvider.get_RootNode() +33
   System.Web.UI.WebControls.SiteMapDataSource.GetNodes() +606
   System.Web.UI.WebControls.SiteMapDataSource.GetTreeView(String viewPath) +66
   System.Web.UI.WebControls.SiteMapDataSource.GetHierarchicalView(String viewPath) +193
   System.Web.UI.HierarchicalDataSourceControl.System.Web.UI.IHierarchicalDataSource.GetHierarchicalView(String viewPath) +39
   System.Web.UI.WebControls.HierarchicalDataBoundControl.GetData(String viewPath) +80
   System.Web.UI.WebControls.Menu.DataBindItem(MenuItem item) +111
   System.Web.UI.WebControls.Menu.PerformDataBinding() +99
   System.Web.UI.WebControls.HierarchicalDataBoundControl.PerformSelect() +114
   System.Web.UI.WebControls.BaseDataBoundControl.DataBind() +125
   System.Web.UI.WebControls.Menu.DataBind() +29
   System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() +104
   System.Web.UI.WebControls.Menu.EnsureDataBound() +70
   System.Web.UI.WebControls.BaseDataBoundControl.OnPreRender(EventArgs e) +43
   System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e, Boolean registerScript) +89
   System.Web.UI.WebControls.Menu.OnPreRender(EventArgs e) +64
   System.Web.UI.Control.PreRenderRecursiveInternal() +170
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Control.PreRenderRecursiveInternal() +292
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint

Hi,

This error occurs if XmlSiteMapProvider does not find sitemap file. Please ensure that you have mapped the file path properly.

Altenatively you can check the solution suggested in below link

http://sanjaysainitech.blogspot.com/2008/02/error-file-websitemap-required-by.html

thank you!

VS 2012 Express for Web Navigation Controls

I am using Windows 8

I have a Web Project with a Master Page that has a Style Sheet. On the Master page I have a SiteMap file. aTreeView control with a SiteMapDataSource control. The Treeview displays properly on the clint pages in the project. When I then add a SiteMapPath
control to the Master Page, it also displays properly in design view.

However, when I Browse the Default (Home) client page in the Browser (IE), I see the following:

- TreeView displays all the nodes, but none are displayed as Links, and parent nodes do not collapse when clicked.

- SiteMapPath displays only the Top Node (Home)

When  I browse other client pages in the browser, the TreeView displays as indicated above, but there is nothing at all displayed in the SiteMapPath control.

I am assuming my problem is affecting both these controls, but I have been unable to figure out that I am doing wrong.

Hi

Navigation controls enable you to add various types of menus to webpages.

These include static and fly-out menus, a tree view, and a navigation path.

It hardly troubleshot according to current information, you could check whether add the controls properly.

Moreover, I hope someone else could give more positive solution.

Kind regards

[RESOLVED]System.Web.UI.WebControls.TreeView: Set custom font for each node

I have a older app that uses an custom ascx control that wraps the Web tree control [Microsoft.Web.UI.WebControls.TreeView]. It used to use the older 1.0 version that allowed a custom node type to control what each node on a branch looked like. Some were
underlined, some were bold (see Below).

Now with the new tree control from System.Web.UI.WebControls.TreeView does not seem to allow the same level of control. Does anyone know how to set the font for an individual node? I see how to set it for parents leafs, but not each node individualy

You may want to consider using the Developer Tools (F12) within a modern browser and inspecting that particular element (Right-click > Inspect Element) which will allow you to access the source and see what CSS styles or classes are being applied
to a particular element. 

You could then write a custom CSS style that would override that previous style and apply the font of your choice to a particular node : 

<style type='text/css'>
    .yourNodeClass { font-family: Segoe UI; color: red; }
</style>

Any other code or markup that you have may be helpful as well.

Rion

Will this work with the newer System.Web.UI.WebControls.TreeView? I didn’t see a way to define a custom NodeType like you could in the older one.

 

Dim nodeCls1 as new TreeNode

Dim nodeCls2 as new TreeNode

If Condition1=true then  

NodeCollection.add(nodeCls1)

Else    

NodeCollection.add(nodeCls2)

End if

should work if I define a style fore each node class?

Hi Irjanzen,

If you want to add class to the TreeNode, I suggest you using the TreeViewNodeDataBound event in TreeView control, like this:

aspx code:

<asp:TreeView ID="TreeView1" 
     ShowExpandCollapse="true" 
     ExpandDepth="0" 
     runat="server" 
     DataSourceID="SiteMapDataSource1" 
     Height="755px" 
     ImageSet="Arrows" 
     OnTreeNodeDataBound="TreeView_TreeNodeDataBound"
....
</asp:TreeView>

cs code:

protected void TreeView_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {
            e.Node.Text = "<div class='treeNodClass'>" + e.Node.Text + "</div>";
        }

Hope it helps.

Best Regards,
Terry Guo

Enable and Disable button in Master Page if Conditon Fulfilled

hey fiends,

       I am having a MasterPage in my project..In my MasterPage there is Button Panel with Five Buttons in it, A TreeView for navigating across Pages and DropDownList for filtering Process.

      My requirement is that when my Home Pge gets Loaded at that time all the above Controls mentioned should be visible but not Enabled except the TreeView Control..

      Later when i Select One of the TreeViewNode(Which vil redirect me to the child page. ex LDC  is my  TreeNode), then at that time My buttons in the buttons panel and my Dropdown shall be Enabled..

Thanks,

Sushant2014

Disable the panel from html markup and enable the same on selection of treeview node.

hey can you list down the code at selection of treeview node…

eg. if i selected node by default is Home, in which i want my button panel to be disabled

but when i click on my second treeview node which is "LDC" i want that Button Panel to be enabled

protected void TreeView2_SelectedNodeChanged(object sender, EventArgs e)
{
    if (TreeView2.SelectedNode.Text == "LDC")
    {
        Panel1.Visible=false;
    }
    else if (...)
    else
    {
       // BLAH BLAH ...
    }
}

Hey i did the Same Code but it is not working…

what is the error you are facing ??? did you saw i edited code.?

if (tree_Menu.SelectedValue == "Data Mapping")
{
Panel2.Enabled = false;

}

if (tree_Menu.SelectedValue == "LDC")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == "CAMP")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == "MDTE")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " LDC")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " CAMP")
{
Panel2.Enabled = true;

}

if (tree_Menu.SelectedValue == " MDTE")
{
Panel2.Enabled = true;

}

This is my Code for Different Nodes

use selectednode.text … 

if (tree_Menu.SelectedNode.Text == "Data Mapping")
{
  ...
}
..
..
..
..

put a breakpoint and see what your are getting in tree_Menu.SelectedNode.Text

it is showing empty..

show your treeview markup …

i have use Site Map Data source for navigation purpose..

below is my treeview markup

<asp:TreeView ID="tree_Menu" runat="server" DataSourceID="SiteMapDataSource1"
ImageSet="Arrows" onselectednodechanged="tree_Menu_SelectedNodeChanged"
BackColor="#FFFF99" ForeColor="Black" style="color: #99FFCC">
<HoverNodeStyle Font-Underline="True" ForeColor="#5555DD" BackColor="#FF9933"
BorderStyle="None" />
<LeafNodeStyle ForeColor="Black" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black"
HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle Font-Underline="True" ForeColor="#5555DD"
HorizontalPadding="0px" VerticalPadding="0px" />
</asp:TreeView>

nd web.sitemap file

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode title="Data Mapping" url="Home.aspx" >
<siteMapNode title="Center Region Mapping">
<siteMapNode title="LDC" url ="LDC.aspx" />
<siteMapNode title="CAMP" url ="CAMP.aspx" />
<siteMapNode title="MDTE" url ="MDTE.aspx" />
</siteMapNode>
<siteMapNode title="Manager Region Mapping">
<siteMapNode title=" LDC" url ="LDC1.aspx" />
<siteMapNode title=" CAMP" url ="CAMP1.aspx" />
<siteMapNode title=" MDTE" url ="MDTE1.aspx" />
</siteMapNode>
<siteMapNode title="Reports">
<siteMapNode title ="HR" url="HR.aspx" />
<siteMapNode title ="Operation" url ="Operation.aspx" />
<siteMapNode title ="Student" url ="Student.aspx" />
</siteMapNode>
</siteMapNode>
</siteMap>

hey guys lend me some solution out of this…m not getting the solution what i wanted..

thanks sushant2014

[RESOLVED]ASP Menu control and centering on page

Hello,

I know this has been discussed before. I have tried multiple threads and ideas to get my menu control to center on the screen but nothing is working.

I know of margin: 0 auto and addign a width but no matter where I place it, nothing happens.

Here is my master page

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="Frontend.master.cs" Inherits="MasterPages_Frontend" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <asp:ContentPlaceHolder id="head" runat="server"></asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div id="PageWrapper">
                <header></header>
                <nav>
                    <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" StaticEnableDefaultPopOutImage="false" DataSourceID="dsSiteMap" CssClass="MainMenu" />
                    <asp:SiteMapDataSource runat="server" ID="dsSiteMap" ShowStartingNode="false" />
                </nav>
                <section id="MainContent">
                    <asp:ContentPlaceHolder id="cpMainContent" runat="server"></asp:ContentPlaceHolder>
                </section>
                <footer></footer>
            </div>
        </form>
    </body>
</html>

My CSS page

body
{
    margin: 0;
    background-color: gray;
}

#PageWrapper
{
    width: 1366px;
    background-color: white;
    margin: auto;
}

nav
{
    width: 1366px;
    height: 36px;
    padding-top: 7px;
    padding-left: 17px;
    background-color: seagreen;
}

nav a
{
    color: #fff;
}

.MainMenu
{
    border: 1px solid #999999;
    width: 1348px;
    height: 19px;
    background-color: #555555;
}

.MainMenu ul 
{
    width: 300px;
    margin: 0 auto;
    display: block;
    padding: 0;
}

My sitemap

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="~/">
        <siteMapNode url="~/Default.aspx" title="Home"  description="Go to the homepage" />
        <siteMapNode url="~/NewTicket.aspx" title="New Ticket"  description="Create a new ticket" />
        <siteMapNode url="~/Search.aspx" title="Search" description="Search tickets" />
    </siteMapNode>
</siteMap>

This is what I have so far. I have weird color combos just to see the different elements at work.

So yeah, wondering what I’m missing.

I was able to get labels I created to center in a panel using the margin: 0 auto and width: auto. But still nothing I try gets my asp:menu control to center in the page.

HaleStorm87

nav
{
    width: 1366px;
    height: 36px;
    padding-top: 7px;
    padding-left: 17px;
    background-color: seagreen;
}

Add text-aligncenter; here. That would do it.

nav
{
    width: 1366px;
    height: 36px;
    padding-top: 7px;
    padding-left: 17px;
    background-color: seagreen;
    text-align: center; 
}

No change. 

I also have tried the following changes. Still no go.

body
{
    margin: 0;
    background-color: gray;
}

#LogoPanel
{
    float: left;
    width: 683px;
    height: 95px
}

#Logo
{
    padding-top: 5px;
}

#HeaderTextPanel
{
    float: right;
    width: 683px;
    height: 95px;
}

#HeaderText
{
    display: block;
    width: auto;
    text-align: center;
    padding-top: 5%;
    padding-left: 40%;
    margin: 0 auto;
    font-family: 'Century Gothic', Arial;
    font-size: 30px;
    font-style: italic;
    font-weight: bold;
    color: #ad1010;
}

#PageWrapper
{
    clear: both;
    width: 1366px;
    background-color: white;
    margin: 0 auto;
}

nav
{
    clear: both;
    width: 1366px;
    background-color: seagreen;
    text-align: center;
}

nav a
{
    color: #fff;
}

.MainMenu
{
    float: none;
    border: 1px solid #999999;
    background-color: #555555;
    display:inline-block;
    margin: 0 auto;
}

I have other controls that are working and that is what doesn’t make sense to me. Like: 

.TableHeaderLabel
{
    display: block;
    width: auto;
    text-align: center;
    margin: 0 auto;
}

That goes right in the center in my panel I have.

Hi HaleStorm87,

Thanks for posting to asp.net forum.

According to your description and code, I see that you want to set the menu item in the center position.

As we know that the menu control will generate a style block by default like below.

<style type="text/css">
	/* <![CDATA[ */
	#Menu1 img.icon { border-style:none;vertical-align:middle; }
	#Menu1 img.separator { border-style:none;display:block; }
	#Menu1 img.horizontal-separator { border-style:none;vertical-align:middle; }
	#Menu1 ul { list-style:none;margin:0;padding:0;width:auto; }
	#Menu1 ul.dynamic { z-index:1; }
	#Menu1 a { text-decoration:none;white-space:nowrap;display:block; }
	#Menu1 a.static { padding-left:0.15em;padding-right:0.15em; }
	#Menu1 a.popout { background-image:url("/WebResource.axd?d=YAYach_zykzn7tRotFpEUhmpY5jFguTb7_Uyi2QJF1l1x_oQ_EqXH_EfDwsBfJ1i6cF4wOKdwC5dLUpBwOweLs5rtvZkrE7sJcO6q67rUwQ1&t=635091197160068157");background-repeat:no-repeat;background-position:right center;padding-right:14px; }
	/* ]]> */
</style>

It will affect your custom css style. Please set the property "IncludeStyleBlock" of menu control as "false". Then set your custom css style.

If any doubt, feel free to back. Thanks.

 

Best Regards!

hi, you can use like this,

<nav>
      <div style="width:100%; margin:0 auto 0 auto;">
              <asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" StaticEnableDefaultPopOutImage="false" DataSourceID="dsSiteMap" CssCla               ss="MainMenu" />
              <asp:SiteMapDataSource runat="server" ID="dsSiteMap" ShowStartingNode="false" />
      </div>
</nav>

Thank you everyone. 

I finally was able to figure it out. 

I edited the styling to my nav parent element:

nav
{
    clear: both;
    text-align: center;
    display: table;
    margin: 0 auto;
}

So instead of having it displayed as a block I set it as a table. Funny thing is it is still rendered as a list.
I have it to clear because I have elements before it that was floated to the left.
I definitely learned a lot more about CSS with this issue. 

Kind of crazy for so much trouble just for one styling. Surprised 

[RESOLVED]Hover to Change Background Image

I have an ASP.NET menu control that worked when left to the default  RenderingMode=Table.  But, in order to comply with the WCAG 2.0 I switched it to  RenderingMode=List.  I can not change ASP.NET from 2 to 4.  It must stay at 2, unfortunately.

Upon changing the menu control to  RenderingMode=List all the menu related WCAG errors went away, but so did the background image functionality.  When a user hovers over a list item of my menu, the background image should change – but that no longer works.
 I didn’t bother submitting the site map file because I don’t think it is relative.  Here is the important code:

<asp:Menu RenderingMode="list" ID="aspMenu"  runat="server" StaticDisplayLevels="1" DataSourceID="SiteMapDataSource1"
                        Orientation="Horizontal" StaticEnableDefaultPopOutImage="False" DynamicPopOutImageUrl="~/images/menuarrow.gif" DynamicHorizontalOffset="25" >
                        <LevelMenuItemStyles>
                            <asp:MenuItemStyle CssClass="menu-level1" HorizontalPadding="25" VerticalPadding="4" />
                            <asp:MenuItemStyle CssClass="menu-level2" HorizontalPadding="25" VerticalPadding="4" />
                            <asp:MenuItemStyle CssClass="menu-level3" />
                            <asp:MenuItemStyle CssClass="menu-level4" />
                        </LevelMenuItemStyles>
                        <DynamicMenuStyle CssClass="aspmenudiv" />
                        <DynamicHoverStyle CssClass="menu-dynamichoverstyle" ForeColor="White" />
                        <StaticHoverStyle CssClass="menu-statichoverstyle" ForeColor="White" />
                        <LevelSubMenuStyles>
                            <asp:SubMenuStyle CssClass="sublevel1" />
                        </LevelSubMenuStyles>
                    </asp:Menu>

/* -------- asp:menu -------------------------- */

.menu-level1, .menu-level2, .menu-level3, .menu-level4
{
    padding: 3px;
    color: #ffffff;
    font: bold 14px Tahoma, Geneva, Verdana, sans-serif;
    border-left-style: solid;
    border-left-width: 0px;
    border-left-color: #044774;
    border-top-color: #044774;
    border-top-style: solid;
    border-top-width: 0px;
    text-align: left;
	z-index:99999;
}

.menu-level1 td a:link, .menu-level2 td a:link,.menu-level3 td a:link,.menu-level4 td a:link
{
    color: #ffffff;
	z-index:99999;
}

.menu-level1 td a:visited, .menu-level2 td a:visited,.menu-level3 td a:visited,.menu-level4 td a:visited
{
    color: #ffffff;
	z-index:99999;
}

.menu-level1
{

	background-image:url('menu_button_level1.jpg'); 
    margin:[0][0][0][0][0];
    font-size: 12px;
    width: 120px;
    text-align: center;
    font-weight: bold;
	z-index:99999;
}

.menu-level1 td a:active
{
    color: #C6D0E4;
	z-index:99999;
}

.menu-level2
{
	background-image:url('menu_button_level1.jpg');
    font-size: 11px;
   	z-index:99999;
}

.menu-level3
{
    background-color: #4C4C4C;
    font-size: 10px;
	z-index:99999;
}

.menu-level4
{
    background-color: #595959;
    font-size: 10px;
	z-index:99999;
}
       
.sublevel1
{
	background-image:url('menu_button_level1.jpg');
    font-variant: small-caps;
    font-size: xx-small;
	z-index:99999;
}

.menu-statichoverstyle, .menu-dynamichoverstyle
{
    font-weight: bold;
	background-image:url('menu_button_level1_hover.jpg');
    color: white;
   	z-index:99999;
}

/* aspmenudiv sets the z-index for the ASP:Menu control so it appears over other controls */
.aspmenudiv
{
	z-index:99999;
	position:relative;
}

.aspmenudiv a
{	
	width:98%;
	display:inline-block;
}

/* -------- End Menu -------------------------- */

Does anyone spot the problem?  I have been goofing with this for hours.  Please help!

Without digging into it too deeply, you might want to change the following section of your CSS : 

margin:[0][0][0][0][0];

to : 

margin: 0;

This may not be the issue at all, but it seemed like a prime opportunity for a syntax error. Could you post the actual source that is getting rendered for your menu? This could simply be a case of the rendered source from your ASP.NET Controls not generating
what you might expect within your CSS. This could also have an issue to do with the location of your actual images in relation to your CSS file (as all images that are referenced within a CSS file are relative to the CSS file itself).

Margin: 0; didn’t work.  Thanks for the idea.

Here is some of the source code:

<div class="aspmenudiv">
      <table border="0" cellpadding="0" cellspacing="0" width="100%">
            <tr style="background-image: url('../App_Themes/Blue/menu_button_level1.jpg')">
                <td colspan="2" align="center">
                    <a href="#ctl00_aspMenu_SkipLink"><img alt="Skip Navigation Links" src="/WebResource.axd?d=aoNHAu9YtRmDUwTqd8xGPvqr7obHWxpP0dyNGmhjOL2MLzCn8sPVEODsCBnVPT1leP99XcDgQx59g0wEvZ6EeLE3OIo1&amp;t=634773866700000000" width="0" height="0" style="border-width:0px;" /></a><div id="ctl00_aspMenu">
	<ul class="level1 sublevel1">
		<li><a title="Home" class="level1 menu-level1" href="/secure/PatientChannel2.aspx?page=desktop">Home</a></li><li><a class="level1 menu-level1">Profile</a><ul class="level2 aspmenudiv">
			<li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=registration&amp;newpage=yes">Patient Profile</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=myfamily">My Family</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=addprofile&amp;newpage=yes">Add Family Member</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=sharehealthinformation&amp;newpage=yes">Share Health Information</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=exportmedicalhistory">Print Medical History</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=usersetting">Settings</a></li>
		</ul></li><li><a class="level1 menu-level1">Healthcare Requests</a><ul class="level2 aspmenudiv">
			<li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=inbox&amp;newpage=yes">Messages</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=evisitmenu&amp;newpage=yes">eVisits</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=appts&amp;newpage=yes">Appointments</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=docs&amp;newpage=yes">Document Center</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=inbox&amp;params=submitforms&amp;params2">Submit Health Forms</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=prescriptions">Prescription Refills</a></li>
		</ul></li><li><a class="level1 menu-level1">Health Records</a><ul class="level2 aspmenudiv">
			<li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=clinicalsummary">Clinical Summary</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=labs">Laboratory</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=vitals&amp;newpage=yes">View Vitals</a></li><li><a class="level2 menu-level2" href="/Secure/PatientChannel2.aspx?page=vitalsoption">Add Or Edit Vitals</a></li>
		</ul></li><li><a class="level1 menu-level1">My Providers</a><ul class="level2 aspmenudiv">
			<li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=provider&amp;newpage=yes">Manage Providers</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=inbox&amp;params=submitforms">Submit Health Forms</a></li>
		</ul></li><li><a class="level1 menu-level1">Resources</a><ul class="level2 aspmenudiv">
			<li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=news">News/Updates</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=feedback">Feedback</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=contact">Contact Us</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=helpfile">Help</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=survey">Survey</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=bloodsugarlog">Blood Sugar Log</a></li><li><a class="level2 menu-level2" href="/secure/PatientChannel2.aspx?page=accountactivity">Account Activity</a></li>
		</ul></li>
	</ul>
</div><a id="ctl00_aspMenu_SkipLink"></a>
                </td>
                <td align="right">
                </td>
            </tr>
        </table>

Forgot to mention, the css and the image files are in the same folder.

Is that the info you needed, Rion?

hi Tualatin,

You can try to use "background-position".

I would suggest that you read this reference below:

Changing Background Images on Hover

http://stackoverflow.com/questions/14803616/changing-background-images-on-hover

Change background image on hover

http://stackoverflow.com/questions/18228248/change-background-image-on-hover

hope it helps!

Hi,

If not solved, I woud suggest to turn to the dev tools in your browser to inspect the markup and see which styles are applied. More likely as the HTML markup changed, some of your CSS rules are not applied anymore and likely requires a selector change.

[RESOLVED]Where are sub Menu?

I set up the second level menu, but when browse in IE8, there is nothing but an empt box, what’s wrong?

img

/img

Press F12 and inspect the submenu code and check the applied CSS. You can change it to get it working.

<asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6" DisappearAfter="10000"
                        DynamicHorizontalOffset="2" Font-Names="Times New Roman" Font-Overline="False"
                        Font-Size="1.2em" ForeColor="Blue" Orientation="Horizontal"
                        StaticSubMenuIndent="10px" Width="144px">
                        <StaticSelectedStyle BackColor="#FFCC66" />
                        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                        <DynamicMenuStyle BackColor="#FFFF99" />
                        <DynamicItemTemplate>
                            <%# Eval("Text") %>
                        </DynamicItemTemplate>
                        <DynamicSelectedStyle BackColor="#FFCC66" />
                        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <StaticHoverStyle BackColor="#990000" ForeColor="White" />
                        <Items>
                            <asp:MenuItem Text="Files" Value="Files">
                                <asp:MenuItem NavigateUrl="~/Home.aspx" Text="Open" Value="Open"></asp:MenuItem>
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="New" Value="New"></asp:MenuItem>
                                <asp:MenuItem Text="Save" Value="Save"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Edit" Value="Edit"></asp:MenuItem>
                            <asp:MenuItem Text="Widows" Value="Widows">
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" Value="About">
                                </asp:MenuItem>
                            </asp:MenuItem>
                        </Items>
                    </asp:Menu>

btw, how to insert a image?

 

it seems microsoft refuse to occupy their space to adopt pics.

another shown

waiting……

zhgart

waiting……

How about post your full code of the page?  I inserted your portion of the code you gave and I got the submenus to appear.  Maybe you have some type of CSS defined that is overriding your display?

Here they are,

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage1.master.cs" Inherits="MasterPage1" %>

<!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 runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 100%;
            border: 2px solid #0000FF;
        }
        .style2
        {
            width: 100%;
            height: 85px;
            border: 1px solid #00FFFF;
            background-color: #00FF00;
        }
        .style3
        {
            width: 188px;
        }
        .style4
        {
            width: 373px;
        }
        .style5
        {
            width: 439px;
        }
    </style>
</head>
<body bgcolor="#ffff99">
    <form id="form1" runat="server">
    <div style="height: 124px; width: 917px; margin-top: 0px;">
        
        <table bgcolor="#CCFF33" class="style2">
            <tr>
                <td class="style3">
                    This is table</td>
                <td class="style4">
                    <asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6" DisappearAfter="10000"
                        DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Overline="False"
                        Font-Size="Medium" ForeColor="#990000" Orientation="Horizontal"
                        StaticSubMenuIndent="10px" Width="330px" Height="52px"
                        style="margin-left: 0px">
                        <StaticSelectedStyle BackColor="#FFCC66" />
                        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                        <DynamicMenuStyle BackColor="#FFFBD6" />
                        <DynamicItemTemplate>
                            <%# Eval("Text") %>
                        </DynamicItemTemplate>
                        <DynamicSelectedStyle BackColor="#FFCC66" />
                        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <StaticHoverStyle BackColor="#990000" ForeColor="White" />
                        <Items>
                            <asp:MenuItem Text="Files" Value="Files">
                                <asp:MenuItem NavigateUrl="~/Home.aspx" Text="Open" Value="Open"></asp:MenuItem>
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="New" Value="New"></asp:MenuItem>
                                <asp:MenuItem Text="Save" Value="Save"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Edit" Value="Edit" NavigateUrl="~/Default.aspx"></asp:MenuItem>
                            <asp:MenuItem Text="Widows" Value="Widows">
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" Value="About">
                                </asp:MenuItem>
                            </asp:MenuItem>
                        </Items>
                    </asp:Menu>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
        <br />
        what is this?<br />
        and line<br />
        outof<br />
        <br />
        how</div>
    <p>
        &nbsp;<p>
        holderHead&nbsp; <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        <p>
            &nbsp;</p>
        <p>
            <br />
        </p>
        
        </asp:ContentPlaceHolder>
    <table cellpadding="2" cellspacing="3" class="style1">
        <tr>
            <td bgcolor="#CCFF99">
                table1</td>
            <td class="style5">
                second</td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style5">
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                third line</td>
            <td bgcolor="#CCFF99" class="style5">
                table 6</td>
        </tr>
    </table>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
        StartingNodeUrl="~/Home.aspx" />
    <p>
        <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" Width="192px">
            <Nodes>
                <asp:TreeNode Text="新建Files" Value="新建Files">
                    <asp:TreeNode NavigateUrl="~/Home.aspx" Text="新建open" Value="新建open">
                    </asp:TreeNode>
                    <asp:TreeNode NavigateUrl="~/About.aspx" Text="新建Save" Value="新建Save">
                    </asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="新建Edit" Value="新建Edit"></asp:TreeNode>
                <asp:TreeNode NavigateUrl="~/About.aspx" Text="新建Help" Value="新建Help">
                </asp:TreeNode>
            </Nodes>
        </asp:TreeView>
    </p>
    <asp:TreeView ID="TreeView2" runat="server" DataSourceID="SiteMapDataSource1"
        ImageSet="Contacts" NodeIndent="10">
        <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
        <HoverNodeStyle Font-Underline="False" />
        <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px"
            VerticalPadding="0px" />
        <DataBindings>
            <asp:TreeNodeBinding DataMember="SiteMapNode" />
            <asp:TreeNodeBinding DataMember="SiteMapNode2" TextField="Url" />
        </DataBindings>
        <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
            HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
    </asp:TreeView>
    <br />
    <br />
    </form>
    </body>
</html>
and here is stylesheet.css, but I haven't yet use them,

body {


}
a:hover
{
    font-family: 'Times New Roman' , Times, serif;
    font-size: large;
    font-weight: bold;
    text-decoration: underline;
    background-color: #00FFFF;
    position: relative;
    z-index: auto;
    visibility: visible;
}

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage1.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <p>
    Hello, this is uniqe page from masterpage.</p>
<p>
    secong section</p>

    <li>
        <p>
        text Chinese    </p>
</li>
      

</asp:Content>

 

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage1.master.cs" Inherits="MasterPage1" %>

<!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 runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
    <style type="text/css">
        .style1
        {
            width: 100%;
            border: 2px solid #0000FF;
        }
        .style2
        {
            width: 100%;
            height: 85px;
            border: 1px solid #00FFFF;
            background-color: #00FF00;
        }
        .style3
        {
            width: 188px;
        }
        .style4
        {
            width: 373px;
        }
        .style5
        {
            width: 439px;
        }
    </style>
</head>
<body bgcolor="#ffff99">
    <form id="form1" runat="server">
    <div style="height: 124px; width: 917px; margin-top: 0px;">
        
        <table bgcolor="#CCFF33" class="style2">
            <tr>
                <td class="style3">
                    This is table</td>
                <td class="style4">
                    <asp:Menu ID="Menu1" runat="server" BackColor="#FFFBD6" DisappearAfter="10000"
                        DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Overline="False"
                        Font-Size="Medium" ForeColor="#990000" Orientation="Horizontal"
                        StaticSubMenuIndent="10px" Width="330px" Height="52px"
                        style="margin-left: 0px">
                        <StaticSelectedStyle BackColor="#FFCC66" />
                        <StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <DynamicHoverStyle BackColor="#990000" ForeColor="White" />
                        <DynamicMenuStyle BackColor="#FFFBD6" />
                        <DynamicItemTemplate>
                            <%# Eval("Text") %>
                        </DynamicItemTemplate>
                        <DynamicSelectedStyle BackColor="#FFCC66" />
                        <DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
                        <StaticHoverStyle BackColor="#990000" ForeColor="White" />
                        <Items>
                            <asp:MenuItem Text="Files" Value="Files">
                                <asp:MenuItem NavigateUrl="~/Home.aspx" Text="Open" Value="Open"></asp:MenuItem>
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="New" Value="New"></asp:MenuItem>
                                <asp:MenuItem Text="Save" Value="Save"></asp:MenuItem>
                            </asp:MenuItem>
                            <asp:MenuItem Text="Edit" Value="Edit" NavigateUrl="~/Default.aspx"></asp:MenuItem>
                            <asp:MenuItem Text="Widows" Value="Widows">
                                <asp:MenuItem NavigateUrl="~/About.aspx" Text="About" Value="About">
                                </asp:MenuItem>
                            </asp:MenuItem>
                        </Items>
                    </asp:Menu>
                </td>
                <td>
                    &nbsp;</td>
            </tr>
        </table>
        <br />
        what is this?<br />
        and line<br />
        outof<br />
        <br />
        how</div>
    <p>
        &nbsp;<p>
        holderHead&nbsp; <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
        
        <p>
            &nbsp;</p>
        <p>
            <br />
        </p>
        
        </asp:ContentPlaceHolder>
    <table cellpadding="2" cellspacing="3" class="style1">
        <tr>
            <td bgcolor="#CCFF99">
                table1</td>
            <td class="style5">
                second</td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td class="style5">
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                third line</td>
            <td bgcolor="#CCFF99" class="style5">
                table 6</td>
        </tr>
    </table>
    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"
        StartingNodeUrl="~/Home.aspx" />
    <p>
        <asp:TreeView ID="TreeView1" runat="server" ShowLines="True" Width="192px">
            <Nodes>
                <asp:TreeNode Text="新建Files" Value="新建Files">
                    <asp:TreeNode NavigateUrl="~/Home.aspx" Text="新建open" Value="新建open">
                    </asp:TreeNode>
                    <asp:TreeNode NavigateUrl="~/About.aspx" Text="新建Save" Value="新建Save">
                    </asp:TreeNode>
                </asp:TreeNode>
                <asp:TreeNode Text="新建Edit" Value="新建Edit"></asp:TreeNode>
                <asp:TreeNode NavigateUrl="~/About.aspx" Text="新建Help" Value="新建Help">
                </asp:TreeNode>
            </Nodes>
        </asp:TreeView>
    </p>
    <asp:TreeView ID="TreeView2" runat="server" DataSourceID="SiteMapDataSource1"
        ImageSet="Contacts" NodeIndent="10">
        <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" />
        <HoverNodeStyle Font-Underline="False" />
        <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px"
            VerticalPadding="0px" />
        <DataBindings>
            <asp:TreeNodeBinding DataMember="SiteMapNode" />
            <asp:TreeNodeBinding DataMember="SiteMapNode2" TextField="Url" />
        </DataBindings>
        <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black"
            HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" />
    </asp:TreeView>
    <br />
    <br />
    </form>
    </body>
</html>

I check up, there is only style4 with only high in it.

 

I havent found anything wrong.  The code seems to work just fine.  I am having no issues using your code and see my submenus appear.

Sometimes I have seen that the changes in styles do not take affect immediately.  Sometimes browser caches the page.  What I would do is close out of your visual studio application and restart it and call up a new browser test on your test page.  Maybe then
the changes in your color will take affect.

I have no other suggestions to help as your code seems to work fine on my end.