locked
menu adapter treating top-level menu items as links RRS feed

  • Question

  • User-546006562 posted

    We have a database-driven menu, where the URL field in the database is null for the top-level menu choices.

    In the sample source code below, "Account Home" should not be a link -- it is the subject heading for links below it.

    When I comment out the menu control adapter in the Browsers file, the top-level menu items are as they should be-- not links.

    Any thoughts on how to fix this?
     

    <div class="AspNet-Menu-Horizontal" id="ctl00_mnuUser">
            <ul class="AspNet-Menu">
                <li class="AspNet-Menu-WithChildren">
                    <a href="javascript:__doPostBack('ctl00$mnuUser','bAccount Home')" class="AspNet-Menu-Link">Account Home</a>
                    <ul>
                        <li class="AspNet-Menu-Leaf"><a href="AccountSummary.aspx" class="AspNet-Menu-Link" title="Summary screen of active accounts">Account Summary</a></li>
                        <li class="AspNet-Menu-Leaf"><a href="TrustCoNews.aspx" class="AspNet-Menu-Link" title="Recent news for the Trust Company">
                                TrustCo News</a></li>
                    </ul>
                </li>

    Tuesday, December 18, 2007 10:38 AM

All replies

  • User-1207404732 posted

    Doesn't seem to me like the URL field is null.

    Can you post more of your code ? your aspx page and your CSSMenuAdapter.cs should be fine.

     

     

    Friday, December 28, 2007 3:08 AM
  • User-538256727 posted

    Have a look at the adapter code, it might become clear what going on [:D]

    if (!String.IsNullOrEmpty(item.NavigateUrl))
                            {
                                writer.WriteAttribute("href", Page.Server.HtmlEncode(menu.ResolveClientUrl(item.NavigateUrl)));
                            }
                            else
                            {
                                writer.WriteAttribute("href", Page.ClientScript.GetPostBackClientHyperlink(menu, "b" +  item.ValuePath.Replace(menu.PathSeparator.ToString(), "\\"), true));
                            }

    If you want different behaviour, just change the adapter. Cssfriendly is just an implementation. I disagree with it all the time ;-)

    Friday, December 28, 2007 7:45 AM