Menu Control - Use OnClick instead of OnMouseOver

Last post 08-22-2007 5:47 PM by Rodashar. 3 replies.

Sort Posts:

  • Menu Control - Use OnClick instead of OnMouseOver

    07-26-2007, 4:14 PM
    • Loading...
    • larrydotnet
    • Joined on 12-09-2002, 1:43 PM
    • Ecuador
    • Posts 92

    Hi everyone,

    Is there a way to display submenues by just clicking the parent menu insted of the default behavior (mouse over it) in the Menu Control?

    I need to prevent showing the menu structure when the user moves over the menu, it is very confusing to have submenues displayed the the user just need to move the mouse to reach another page option.   Please is you know to to do that please let me know.

    The real click event needs to be just on the the leaf menu (last one of each structure).

    Please, give me some advise.

    Thanks.

     

    Larry Suárez.
  • Re: Menu Control - Use OnClick instead of OnMouseOver

    07-26-2007, 5:23 PM
    Answer
    • Loading...
    • Rodashar
    • Joined on 07-25-2007, 5:46 PM
    • Calgary
    • Posts 110

    What you could do is create a custom user control and add a Menu control to it. Then in the code override the render method and replace the onmouseover with the onclick. (Example below). The only troble with this would be if you were using the SiteMap to fill your menu. If the SiteMapNodes have a NavigateUrl assigned then they may use the onclickevent. I'd have to look into this further. I'm not sure what you would do for closing the menu. I guess you could just leave the on mouseout and it would work. In theory you'd just call the same javascript function and it should work. Let me know if this helps.

     

    //Override the Render method to replace the onmouseover

    protected override void Render(HtmlTextWriter writer) {

    StringBuilder stringBuilder = new StringBuilder();

    StringWriter stringWriter = new StringWriter(stringBuilder);

    HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);

    base.Render(htmlWriter);

    string html = stringBuilder.ToString();

    html = html.Replace("onmouseover="Menu_HoverStatic(this)""","onclick="Menu_HoverStatic(this)""");

    writer.Write(html);

    }

    Remeber to mark as Answer if someone's answer helped you.
  • Re: Menu Control - Use OnClick instead of OnMouseOver

    08-22-2007, 5:37 PM
    • Loading...
    • larrydotnet
    • Joined on 12-09-2002, 1:43 PM
    • Ecuador
    • Posts 92

    Thank you very much.  What i did was to create a class that inherits from Menu and overrided the Render metohd using your code.  that worked for me.

    Larry Suárez.
  • Re: Menu Control - Use OnClick instead of OnMouseOver

    08-22-2007, 5:47 PM
    • Loading...
    • Rodashar
    • Joined on 07-25-2007, 5:46 PM
    • Calgary
    • Posts 110

    Glad I could be of help :D

    Remeber to mark as Answer if someone's answer helped you.
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter