Problem with Menu Control

Last post 03-21-2008 6:26 PM by Moneypenny. 12 replies.

Sort Posts:

  • Problem with Menu Control

    03-16-2008, 7:50 PM
    • Member
      3 point Member
    • Moneypenny
    • Member since 12-18-2007, 12:30 AM
    • Posts 19

    I hope someone can help me with a problem I'm having with the Menu Control.

    When I put a menu control on a page and run the application, the page will run fine, but about every 10 page loads I get a runtime error that says the 'page loaded with errors'. When this happens, the flyout element of the menu won't work, if I refresh the page then everything works fine again. I'm using the Menu control without any additional styling or features (for testing purposes) but the problem still occurs. This is the worst kind of problem, if it happened every time it would be easier to nail down.

    Some technical specifications: I'm using VS 2005 on my local machine and running the application using the built in web server (not IIS). Operating system is XP Pro, Browser is IE 6. Framework is ASP.NET 2 and the language is C#.

    This problem has me completely stumped, I've tried putting the menu on an empty page just in case the problem is being caused by other page elements (same result) and even more strangely everything works fine in FireFox. Visual Studio is not finding any problems in Debug mode either.

    I hope someone can help here, or is this just a bug in the menu control.

     thanks

  • Re: Problem with Menu Control

    03-18-2008, 2:11 AM

    Hi, 

    Moneypenny:
    When this happens, the flyout element of the menu won't work, if I refresh the page then everything works fine again.

    It's so weird.

    Base on your description, you have test the menu on an empty page, but how about try to create a new project to test it?

    If you still get the error, you could post the detail error message and your application here, so we can try to find the cause of the problem by using it.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Problem with Menu Control

    03-18-2008, 5:33 AM
    Answer
    • All-Star
      16,552 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,295
    • TrustedFriends-MVPs

    The error message sounds like an IE message, which means it's a JavaScript issue. Can you try it in IE7?

    It could be that there's a problem with local web server, not serving scripts correctly every time; the javascript the menu uses is stored as a resource.

    If the problem persists, then you might want to try the CSS Adapters (http://www.asp.net/cssadapters/), which change the rendering of the Menu control. This still uses some script for IE6, but the script is a separate file so the browser takes responsibility to loading it.

    d

  • Re: Problem with Menu Control

    03-18-2008, 8:08 PM
    • Member
      3 point Member
    • Moneypenny
    • Member since 12-18-2007, 12:30 AM
    • Posts 19

    Hi guys,

    Thanks for your replies, Amanda, in response to your post I did what you suggested and created a new project, and the problem still occurs (approx every 20 refreshes of the page). Here is the source code for the generated page (I hope it makes more sense to you than it does to me)

    <!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><title>
     Untitled Page
    </title><style type="text/css">
     .Menu1_0 { background-color:white;visibility:hidden;display:none;position:absolute;left:0px;top:0px; }
     .Menu1_1 { text-decoration:none; }
     .Menu1_2 {  }

    </style></head>
    <body>
        <form name="form1" method="post" action="default.aspx" id="form1">
    <div>
    <input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
    <input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJMzYzNDc5MjE1D2QWAgIDD2QWAgIBDzwrAA0BDBQrAAMFBzA6MCwwOjEUKwACFgQeBFRleHQFFEFubml2ZXJzYXJ5IEJhbGxvb25zHgVWYWx1ZQUBMRQrAAYFEzA6MCwwOjEsMDoyLDA6MywwOjQUKwACFgQfAAUOTG92ZSAmIFJvbWFuY2UfAQUBMWQUKwACFgQfAAUJQmlydGhkYXlzHwEFATJkFCsAAhYEHwAFCFdlZGRpbmdzHwEFATNkFCsAAhYEHwAFDVRlc3QgQ2F0YWdvcnkfAQUBN2QUKwACFgQfAAUKVGVzdCBjYXQgMh8BBQE4ZBQrAAIWBB8ABRVCYWxsb29ucyBmb3IgQ2hpbGRyZW4fAQUBMhQrAAQFCzA6MCwwOjEsMDoyFCsAAhYEHwAFEE1lc3NhZ2UgQmFsbG9vbnMfAQUBNGQUKwACFgQfAAUIQ2FydG9vbnMfAQUBNWQUKwACFgQfAAUNTWlzY2VsbGFuZW91cx8BBQE2ZGRkg4HlYT2+tp6Jdrk21l0yy1mZFCU=" />
    </div>

    <script type="text/javascript">
    <!--
    var theForm = document.forms['form1'];
    if (!theForm) {
        theForm = document.form1;
    }
    function __doPostBack(eventTarget, eventArgument) {
        if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
            theForm.__EVENTTARGET.value = eventTarget;
            theForm.__EVENTARGUMENT.value = eventArgument;
            theForm.submit();
        }
    }
    // -->
    </script>


    <script src="/Web/WebResource.axd?d=1lDDaydImj2iAP3BGX8fJg2&amp;t=633332240892656250" type="text/javascript"></script>


    <script src="/Web/WebResource.axd?d=DKJ1bgR44SjNn4rmVvxflQ2&amp;t=633332240892656250" type="text/javascript"></script>
       
       
         <a href="http://forums.asp.net/AddPost.aspx?ReplyToPostID=2239182&Quote=False#Menu1_SkipLink"><img alt="Skip Navigation Links" src="/Web/WebResource.axd?d=nR6Mg-EsTMM9vKUm7U-5CA2&amp;t=633332240892656250" width="0" height="0" style="border-width:0px;" /></a><table id="Menu1" class="Menu1_2" cellpadding="0" cellspacing="0" border="0">
     <tr onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n0">
      <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
       <tr>
        <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1')">Anniversary Balloons</a></td><td style="width:0;"><img src="/Web/WebResource.axd?d=3DCNoT--IhkEHhbHl7akkE88kG07A_iYO2ZwXnYu_JI1&amp;t=633332240892656250" alt="Expand Anniversary Balloons" style="border-style:none;vertical-align:middle;" /></td>
       </tr>
      </table></td>
     </tr><tr onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n1">
      <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
       <tr>
        <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','2')">Balloons for Children</a></td><td style="width:0;"><img src="/Web/WebResource.axd?d=3DCNoT--IhkEHhbHl7akkE88kG07A_iYO2ZwXnYu_JI1&amp;t=633332240892656250" alt="Expand Balloons for Children" style="border-style:none;vertical-align:middle;" /></td>
       </tr>
      </table></td>
     </tr>
    </table><div id="Menu1n0Items" class="Menu1_0">
     <table border="0" cellpadding="0" cellspacing="0">
      <tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n2">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1\\1')">Love & Romance</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n3">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1\\2')">Birthdays</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n4">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1\\3')">Weddings</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n5">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1\\7')">Test Catagory</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n6">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','1\\8')">Test cat 2</a></td>
        </tr>
       </table></td>
      </tr>
     </table><div class="Menu1_0" id="Menu1n0ItemsUp" onmouseover="PopOut_Up(this)" onmouseout="PopOut_Stop(this)" style="text-align:center;">
      <img src="/Web/WebResource.axd?d=MBUp22YxUKtnN7u7cSjXLTIwIKcfHipwNQ-eNd85rpM1&amp;t=633332240892656250" alt="Scroll up" />
     </div><div class="Menu1_0" id="Menu1n0ItemsDn" onmouseover="PopOut_Down(this)" onmouseout="PopOut_Stop(this)" style="text-align:center;">
      <img src="/Web/WebResource.axd?d=pAU1C5tH-oYqvwI_ufHi6NSK176HybLoGgI2KUUpI0M1&amp;t=633332240892656250" alt="Scroll down" />
     </div>
    </div><div id="Menu1n1Items" class="Menu1_0">
     <table border="0" cellpadding="0" cellspacing="0">
      <tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n7">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','2\\4')">Message Balloons</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n8">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','2\\5')">Cartoons</a></td>
        </tr>
       </table></td>
      </tr><tr onmouseover="Menu_HoverDynamic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)" id="Menu1n9">
       <td><table cellpadding="0" cellspacing="0" border="0" width="100%">
        <tr>
         <td style="white-space:nowrap;width:100%;"><a class="Menu1_1" href="javascript:__doPostBack('Menu1','2\\6')">Miscellaneous</a></td>
        </tr>
       </table></td>
      </tr>
     </table><div class="Menu1_0" id="Menu1n1ItemsUp" onmouseover="PopOut_Up(this)" onmouseout="PopOut_Stop(this)" style="text-align:center;">
      <img src="/Web/WebResource.axd?d=MBUp22YxUKtnN7u7cSjXLTIwIKcfHipwNQ-eNd85rpM1&amp;t=633332240892656250" alt="Scroll up" />
     </div><div class="Menu1_0" id="Menu1n1ItemsDn" onmouseover="PopOut_Down(this)" onmouseout="PopOut_Stop(this)" style="text-align:center;">
      <img src="/Web/WebResource.axd?d=pAU1C5tH-oYqvwI_ufHi6NSK176HybLoGgI2KUUpI0M1&amp;t=633332240892656250" alt="Scroll down" />
     </div>
    </div><a id="Menu1_SkipLink"></a>
       
       
    <div>

     <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWCwKy/a/uAQLR87fGDQLQ87fGDQKai6b6BAKBnMTPDgKk9evUCAK4kvP5AwKP+LO7CwLKz4m6BQLxoK+PDwKUuc2UCc/JzBv8bxS7oBFP5NSRIFxWLxoO" />
    </div>

    <script type="text/javascript">
    <!--
    var Menu1_Data = new Object();
    Menu1_Data.disappearAfter = 500;
    Menu1_Data.horizontalOffset = 0;
    Menu1_Data.verticalOffset = 0;
    // -->
    </script>
    </form>
    </body>
    </html>

     

    The message that accompanies it is: Line 719,   Char 76,   Error Expected ')',   Code 0

     

  • Re: Problem with Menu Control

    03-19-2008, 10:13 PM

    hi.

    I meant that is NOT the html that is renderend but the code in your .aspx file. we hope to repro your problem in our local.

     

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Problem with Menu Control

    03-19-2008, 11:33 PM
    • Member
      3 point Member
    • Moneypenny
    • Member since 12-18-2007, 12:30 AM
    • Posts 19

    Sorry Amanda, I misunderstood your request. Anyway here's the aspx and code behind file.

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!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>Untitled Page</title>

    </head>

    <body>

    <form id="form1" runat="server">

    <asp:Menu ID="Menu1" runat="server" >

    </asp:Menu>

    </form>

    </body>

    </html>

     

    using System;

    using System.Data;

    using System.Configuration;

    using System.Web;

    using System.Web.Security;

    using System.Web.UI;

    using System.Web.UI.WebControls;

    using System.Web.UI.WebControls.WebParts;

    using System.Web.UI.HtmlControls;

    using System.Collections.Generic;

    using CatAccess;

    public partial class _Default : System.Web.UI.Page

    {

    protected void Page_Load(object sender, EventArgs e)

    {

    if (!Page.IsPostBack)

    {

    PopulateMenuControl();

    }

    }

     

     

    // This method is used to populate the Menu Control

    private void PopulateMenuControl()

    {

    List<DepartmentsWrapper> depts = CatalogAccess.GetDepartmentsTest();

    List<CategoriesWrapper> cats = CatalogAccess.GetCategoriesTest();

    MenuItem parentNode = null;foreach (DepartmentsWrapper depts1 in depts)

    {

    parentNode = new MenuItem(depts1.Name, depts1.DepartmentID.ToString());

    int deptId = depts1.DepartmentID;foreach (CategoriesWrapper cats1 in cats)

    {

    if (cats1.DepartmentID == deptId)

    {

    MenuItem childNode = new MenuItem(cats1.Name, cats1.CategoryID.ToString());

    parentNode.ChildItems.Add(childNode);

    }

    }

    Menu1.Items.Add(parentNode);

    }

    }

    }

  • how to get the controls id if we use the master page

    03-19-2008, 11:44 PM
    • Member
      2 point Member
    • swapna perala
    • Member since 03-18-2008, 5:48 AM
    • Posts 1

    Hi All,

           iam using the master page in my web form so iam uanable to get the controls id if anybody knows help me

    Thanks,

    Swapna. 

     

  • Re: how to get the controls id if we use the master page

    03-20-2008, 3:04 AM

    Hi  Swapna,

    swapna perala:
      iam using the master page in my web form so iam uanable to get the controls id if anybody knows help me

    Try to use the control's clientID, you can get the control's client by viewing the page source after the page render. OR you also can get the control's clientid in the codebehind:

    For example:

    string str =  this.label.ClientID;

    Hope it helps.

    Amanda Wang
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Problem with Menu Control

    03-20-2008, 3:45 AM
    • Contributor
      2,273 point Contributor
    • Johnson2007
    • Member since 05-17-2007, 7:19 AM
    • Posts 449

    Moneypenny:
    List<DepartmentsWrapper> depts = CatalogAccess.GetDepartmentsTest();

    List<CategoriesWrapper> cats = CatalogAccess.GetCategoriesTest();

     

    Hi,

    I notice that in your PopulateMenuControl() method there are two line as above. I guess they must be static methods or the CatalogAccess is a static class. Try to add the code as following just behind these two lines code. I suggest this because I had met a similar problem, and it may because the static method or static class substance have disappeard in the server memory.

     It may not get the affect what you want. My second suggestion is that translate the two methods above to the dynamic methods or change the CatalogAccess class to a NOT STATIC class (if it is).

     

    if(depts == null || cats == null)
    {
    return;
    }
      

     

     

    Johnson
  • Re: Problem with Menu Control

    03-20-2008, 7:57 PM
    • Member
      3 point Member
    • Moneypenny
    • Member since 12-18-2007, 12:30 AM
    • Posts 19

    Okay here's the story so far..

    I've tried the line of code you gave me Johnson2007 and in the new application I created it made the menu work perfectly in IE  (hooray) but it doesn't work in Firefox still (boo) the flyout part of the menu freezes on page load (approx every 2-3 loads). In my original app no change unfortunately in either browser (double boo). I also tried converting the class from Static as you suggested, still no luck.

    However I did turn on the allow script debug option in IE (I don't know where that option is in FireFox) and found that after the runtime error dialog box appeared and I clicked no when asked if I want to debug, the page errored again when i moused over the menu (didn't need to click anything)

    Suggestions anyone ??

     

  • Re: Problem with Menu Control

    03-21-2008, 3:55 AM
    • Contributor
      2,273 point Contributor
    • Johnson2007
    • Member since 05-17-2007, 7:19 AM
    • Posts 449

    To see the javascript error in Firefox, please click on "Tool"  menu and click on "Error Console" and roll down to the last few messages in the list.

    To debug javascript in Firefox, please use the Venkman. More information you can see http://www.mozilla.org/projects/venkman/

    Johnson
  • Re: Problem with Menu Control

    03-21-2008, 4:48 AM
    • All-Star
      16,552 point All-Star
    • Dave Sussman
    • Member since 06-17-2002, 11:53 AM
    • UK
    • Posts 2,295
    • TrustedFriends-MVPs

    I'd actually recommend the FireBug add-in for FireFox; it gives good script debugging as well as excellent CSS tools.

  • Re: Problem with Menu Control

    03-21-2008, 6:26 PM
    • Member
      3 point Member
    • Moneypenny
    • Member since 12-18-2007, 12:30 AM
    • Posts 19

    Problem fixed !!

    I downloaded the debugging plug in for Firefox which gave me a much better look at the problem (very impressive bit of software) Anyway, the problem did indeed seem to be caused by the resource file storing the menu scripts.   Sooooo, I downloaded the CSS adaptor kit, spent an afternoon getting my head round it, added it to the site and bingo, everything worked as it should.  Thanks to everyone who offered advice particularly Dave Sussman, you had it nailed from the start.

    All I have to do now is figure out the CSS to make the menu look nice ...sigh.

Page 1 of 1 (13 items)