Why is my ASP.net navigation menu rendering different after publishing.

I am using Visual Web Developer 2010 with the ASP.net Web template that comes with it. It has a navigation menu that I have modified and added to. It looks good in development but publishing in IIS 5.1 it loses the boxes containing the link text. I have used framework 4.0 for development and IIS 5.1.

I am sure the probles is around here,

div.menu ul li a, div.menu ul li a:visited
{
    background-color: #465c71;
    border: 1px #4e667d solid;
    color: #dde4ec;
    display: block;
    line-height: 1.35em;
    padding: 4px 20px;
    text-decoration: none;
    white-space: nowrap;
}


<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" Enabled="true">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/View.aspx" Text="View"/>
                        <asp:MenuItem NavigateUrl="~/Log.aspx" Text="Log"/>
                        <asp:MenuItem NavigateUrl="~/Status.aspx" Text="Status"/>
                        <asp:MenuItem NavigateUrl="~/Modify.aspx" Text="Modify"/>
                        <asp:MenuItem NavigateUrl="~/New.aspx" Text="New"/>
                        <asp:MenuItem NavigateUrl="~/Admin.aspx" Text="Admin"/>
                    </Items>
                </asp:Menu>


Menu
dearnessAsked:
Who is Participating?
 
Vikram Singh SainiConnect With a Mentor Software Engineer cum AD DeveloperCommented:
Hello dearness,

After reading all your rendered source code, I think I have got point.

Since as you mentioned that you have set website's asp.net version to 4.0 but still it is showing problem.

Reason:

In your web.config if the following line is present:
<pages controlRenderingCompatibilityVersion="3.5" /> then the Menu control uses HTML table elements as shown in comment id 37817163.

Solution?

1. In your web.config change the above line to:
<pages controlRenderingCompatibilityVersion="4.0" /> then the Menu control uses HTML listitem elements by default.

2.
If you don't want to modify above line in web.config, modify menu control in .aspx as:
<asp:Menu RenderingMode="List" />

Now after modifying files your menu and css would work fine. And source code would show menu as ul and li.
0
 
dearnessAuthor Commented:
Im am using internet explorer 8.0
0
 
Paul MacDonaldDirector, Information SystemsCommented:
Are you sure the appropriate CSS is being deployed?  Does everything else render okay?
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
I suppose that there is no problem with css.

But you need to make sure that while deploying website on IIS 5.1 have you set Framework to 4.0 for that website or virtual directory in particular?

Because asp:menu are rendered as table while asp.net framework is set to 2.0 and in div if set to 4.0. So recheck your rendered source code for menu. I'm sure it would be in displaying menu in table format.

And this is the reason why css can't be applied as that is set for div not for tables.

So. What to do? Share with us your rendered source code. We need to tweak css for table (case .net 2.0) or just set framework to 4.0.
0
 
dearnessAuthor Commented:
Thank you for your replies.
Paulmacd,
I made some changes to the CSS in web developer and when I press F12 in the IIS runtime browser I see the changes made to the CSS, for example changed background to black as below, but the menu never changes. I can change the <h1> attribute in CSS and my heading does change. I would say the correct CSS is being applied but not working with menu.

div.menu ul li a, div.menu ul li a:visited
{
    background-color: black;

CSS changed F12
vs00saini,
I have verified v4.0.30319 in IIS default website, virtual and development.

Is this the code you are asking for?
CSS..............
/* TAB MENU  
----------------------------------------------------------*/

div.hideSkiplink
{
    background-color:#3a4f63;
    width:100%;
}

div.menu
{
    padding: 4px 0px 4px 8px;
}

div.menu ul
{
    list-style: none;
    margin: 0px;
    padding: 0px;
    width: auto;
}

div.menu ul li a, div.menu ul li a:visited
{
    background-color: #465c71;
    border: 1px #4e667d solid;
    color: #dde4ec;
    display: block;
    line-height: 1.35em;
    padding: 4px 20px;
    text-decoration: none;
    white-space: nowrap;
}

div.menu ul li a:hover
{
    background-color: #bfcbd6;
    color: #465c71;
    text-decoration: none;
}

div.menu ul li a:active
{
    background-color: #465c71;
    color: #cfdbe6;
    text-decoration: none;
}


HTML...............
<div class="clear hideSkiplink">
                <asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false" IncludeStyleBlock="false" Orientation="Horizontal" Enabled="true">
                    <Items>
                        <asp:MenuItem NavigateUrl="~/Default.aspx" Text="Home"/>
                        <asp:MenuItem NavigateUrl="~/View.aspx" Text="View"/>
                        <asp:MenuItem NavigateUrl="~/Log.aspx" Text="Log"/>
                        <asp:MenuItem NavigateUrl="~/Status.aspx" Text="Status"/>
                        <asp:MenuItem NavigateUrl="~/Modify.aspx" Text="Modify"/>
                        <asp:MenuItem NavigateUrl="~/New.aspx" Text="New"/>
                        <asp:MenuItem NavigateUrl="~/Admin.aspx" Text="Admin"/>
                    </Items>
                </asp:Menu>
            </div>
0
 
dearnessAuthor Commented:
By the way the menu HTML is in a Master page.
0
 
dearnessAuthor Commented:
I think this is the code you are asking for, navigation shows as a table.

Rendered Code?
0
 
dearnessAuthor Commented:
version 4.0 in virtual
0
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
ok! Share the html source code, from the browser.
0
 
dearnessAuthor Commented:
vs00saini,
Im a bit out of my depth with this, hope I am giving you the right information.

See modified attachement, PM Source Code.
PM-Web.txt
PM-Source-Code.htm
0
 
Paul MacDonaldConnect With a Mentor Director, Information SystemsCommented:
And the Master Page references the CSS?
0
 
dearnessAuthor Commented:
<head runat="server">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <title></title>
    <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
    <asp:ContentPlaceHolder ID="HeadContent" runat="server">
    </asp:ContentPlaceHolder>
</head>

I trying to copy this example for framework 4.0 but still no luck,
http://msdn.microsoft.com/en-us/library/ms366731.aspx
0
 
dearnessAuthor Commented:
if I remove this line from the master page,
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />

I lose all formatting so it must be working correctly?
0
 
dearnessAuthor Commented:
I just created a new website with Visual Web Developer with all default settings and still the menu does not format once published. Works Ok in development.

 Default New Website
0
 
dearnessAuthor Commented:
vs00saini,
<pages controlRenderingCompatibilityVersion="3.5" /> does not appear in my web.config,
but <asp:Menu RenderingMode="List" /> certainly fixed the problem.
Thank you very much, I have spent hours on this and its so frustrating to have one small keyword fix the problem. Learnt alot.
0
 
Vikram Singh SainiSoftware Engineer cum AD DeveloperCommented:
<pages controlRenderingCompatibilityVersion="3.5" /> does not appear in my web.config,

Then I assume that you have set asp.net 4.0 framework for your website but either it has not been set for the very same virtual directory. Recheck it and if you say that it is set, then my next suggestion is to reset iis using iisreset command in cmd prompt.

I think that will make IIS to make changes to its website and virtual directory to be updated in meta file.
0
 
dearnessAuthor Commented:
great information. I am not at the application PC now but will have look tomorrow.
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.