Click here to Skip to main content
15,889,867 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using menu control with little bit animation.
I am using two more munu's. I don't want to use all the menu's.
I want to display only one menu control at a time based on my condition.
I am getting error "object required:null identified in the "DIV"
I did't use any "DIV" in my code. why it shows null identied in the "DIV"
why the error will come...?
see my complete code as below...
JQuery
-------
HTML
<script type="text/javascript">
        $(function () {
            $("ul.level1 li").hover(function () {
                $(this).stop().animate({ opacity: 0.7, width: "210px" }, "slow");
            }, function () {
                $(this).stop().animate({ opacity: 1, width: "170px" }, "slow");
            });
        });
   </script>

CSS Code
--------
CSS
li 
 { 
            border:1px solid black; 
            padding:2px 2px 2px 2px; 
            width:210px; 
            background-color:#82C0FF;
            color:black; 
            cursor:pointer;
 }
 a { color:black; font: bold 11px Verdana; }

ASPX Page
---------
ASP.NET
<tr>
                 <td width="100%">
                   <%If Session("Admin") = "1" Then%>
                          <ul>
                          <asp:Menu ID="AdminMenu" runat="server" Orientation="Horizontal" RenderingMode="List">
                              <Items>
                                  <asp:MenuItem NavigateUrl="~/Home.aspx"  Text="Home" Value="Home"  />
                                  <asp:MenuItem  Text="Master" Value="first">
                                          <asp:MenuItem  Text="A" Value="A"></asp:MenuItem>
                                          <asp:MenuItem Text="B" Value="B"></asp:MenuItem>
                                          <asp:MenuItem  Text="C" Value="C"></asp:MenuItem>
                                          <asp:MenuItem Text="D" Value="D"></asp:MenuItem>
                                  </asp:MenuItem>
                                  <asp:MenuItem  Text="Transaction" Value="Second">
                                          <asp:MenuItem  Text="A" Value="A"></asp:MenuItem>
                                          <asp:MenuItem Text="B" Value="B"></asp:MenuItem>
                                  </asp:MenuItem>
                                   <asp:MenuItem  Text="Reports" Value="Third">
                                          <asp:MenuItem  Text="A" Value="A"></asp:MenuItem>
                                          <asp:MenuItem  Text="B" Value="B"></asp:MenuItem>
                                  </asp:MenuItem>
                                  <asp:MenuItem NavigateUrl="~/Others.aspx"  Text="Others" Value="Others"  />
                              </Items>
                          </asp:Menu>
                          </ul>
                  <%End If%>
                  </td>
                  <td style="width:400px; vertical-align:top">
                      <asp:ContentPlaceHolder id="CONTENT" Runat="Server"/>
                  </td>
          </tr>
           <tr>
                 <td width="100%">
                   <%If Session("Emp") = "2" Then%>
                          <ul>
                          <asp:Menu ID="AdminMenu" runat="server" Orientation="Horizontal" RenderingMode="List">
                              <Items>
                                  <asp:MenuItem NavigateUrl="~/Home.aspx"  Text="Home" Value="Home"  />
                                  <asp:MenuItem  Text="Transaction" Value="Second">
                                          <asp:MenuItem  Text="A" Value="A"></asp:MenuItem>
                                          <asp:MenuItem Text="B" Value="B"></asp:MenuItem>
                                  </asp:MenuItem>
                                   <asp:MenuItem  Text="Reports" Value="Third">
                                          <asp:MenuItem  Text="A" Value="A"></asp:MenuItem>
                                          <asp:MenuItem  Text="B" Value="B"></asp:MenuItem>
                                  </asp:MenuItem>
                                  <asp:MenuItem NavigateUrl="~/Others.aspx"  Text="Others" Value="Others"  />
                              </Items>
                          </asp:Menu>
                          </ul>
                  <%End If%>
                  </td>
                  <td style="width:400px; vertical-align:top">
                      <asp:ContentPlaceHolder id="ContentPlaceHolder1" Runat="Server"/>
                  </td>
          </tr>



The error I get makes NO sense to me?




Object required

if (this.element.tagName === 'DIV') {

is highlighted in the extract from the system generated JavaScript below.
(But I'm using VB.Net - Framework 4.0 - so, DIV should be div - but I have no div and can't see where to introduce one?)


if (!window.Sys) { window.Sys = {}; }
if (!Sys.WebForms) { Sys.WebForms = {}; }
Sys.WebForms.Menu = function(options) {
this.items = [];
this.depth = options.depth || 1;
this.parentMenuItem = options.parentMenuItem;
this.element = Sys.WebForms.Menu._domHelper.getElement(options.element);
if (this.element.tagName === 'DIV') {
var containerElement = this.element;
this.element = Sys.WebForms.Menu._domHelper.firstChild(containerElement);
this.element.tabIndex = options.tabIndex || 0;
options.element = containerElement;
options.menu = this;
this.container = new Sys.WebForms._MenuContainer(options);
Sys.WebForms.Menu._domHelper.setFloat(this.element, this.container.rightToLeft ? "right" : "left");
}
else {
this.container = options.container;
this.keyMap = options.keyMap;
}
Posted
Updated 13-Dec-11 21:45pm
v3
Comments
Al Moje 14-Dec-11 3:05am    
I think it is better to do such filtering or adding menus in code behind which defends on access level...

1 solution

Hi,

See this sample
In your site.master client page:

C#
<body>
    <form id="Form1" runat="server">
    <div class="page">
        <div class="header">
            <div class="title">
                <h1>
                    My Industrial Corporation
                </h1>
            </div>
            <div class="loginDisplay">
                <asp:loginview id="HeadLoginView" runat="server" enableviewstate="false" xmlns:asp="#unknown">
                    <anonymoustemplate>
                        [ <a href="~/Account/Login.aspx" id="HeadLoginStatus" runat="server">Log In</a>
                        ]
                    </anonymoustemplate>
                    <loggedintemplate>
                        Welcome 
                            <asp:loginname id="HeadLoginName" runat="server" />
                        ! [
                        <asp:loginstatus id="HeadLoginStatus" runat="server" logoutaction="Redirect" logouttext="Log Out">
                            LogoutPageUrl="~/" />
                        ]
                    </asp:loginstatus></loggedintemplate>
                </asp:loginview>
            </div>
            <div class="clear hideSkiplink">
                <asp:menu id="NavigationMenu" runat="server" cssclass="menu" enableviewstate="false" xmlns:asp="#unknown">
                    IncludeStyleBlock="false" Orientation="Horizontal">
                    <items>
                        <asp:menuitem navigateurl="~/Default.aspx" text="Home" />
                    </items>
                </asp:menu>
            </div>
        </div>
        <div class="main">
            <asp:contentplaceholder id="MainContent" runat="server" xmlns:asp="#unknown" />
        </div>
        <div class="clear">
        </div>
    </div>
    <div class="footer">
        <table width="100%">
            <tr>
                <td colspan="2" align="center" class="clsTblRowVs">
                    <a href="Default.aspx">Terms</a> | <a href="Default.aspx">Contact Us</a> | <a href="/About.aspx">
                        Learn More</a>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>


Then in your Default.aspx code behind:
Sample:

C#
protected void Page_Load(object sender, EventArgs e)
      {
          //<asp:menuitem navigateurl="~/About.aspx" text="About" xmlns:asp="#unknown" />
           MenuItem homeSub = new MenuItem("Show Room", "", "", "Default.aspx");
           //1=====================================================
          MenuItem topMenu01 = new MenuItem("Show Room", "", "", "Default.aspx");
          // 1.
          MenuItem subMenu01 = new MenuItem("Products", "", "", "Category.aspx?cn=Show Room -> Products Galary");
          topMenu01.ChildItems.Add(subMenu01);

          NavigationMenu.Items.Add(topMenu01);
          if (Page.User.Identity.IsAuthenticated)
          {
              // For no role setup user(s)



              if (Page.User.IsInRole("admin"))
              {
                  //2===============================================================
                  MenuItem topMenu02 = new MenuItem("Admin. Opns.", "", "", "Default.aspx");
                  // 1.
                  MenuItem subMenu21 = new MenuItem("Categories", "", "", "Categories.aspx?cn=Admin. Operations -> Product Category");
                  topMenu02.ChildItems.Add(subMenu21);
                  // 2.
                  MenuItem subMenu22 = new MenuItem("Products", "", "", "Prod.aspx?cn=Admin. Operations -> Product Maintenance");
                  topMenu02.ChildItems.Add(subMenu22);
                  NavigationMenu.Items.Add(topMenu02);

              }

          }
      }
  }


Please be reminded to vote if could help so that others may consider as answer...

Above sample uses ASP.Net 4.0

Hope this coul help...

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900