how to add click event to menu item RRS feed

  • Question

  • User-1392959185 posted

     I have a menu in the  master page. I want to add javascript click event to a menu Item

    from the content page the content page

    how i can achive this ?

    Sunday, September 20, 2009 12:09 PM


  • User-25801601 posted

     First off, what kind of menu?  What control are you using?

    Are you wanting different content pages to have different onclick effects, or are the effects static across all content pages?  If so you don't need to define them in the content pages, you can do it in the master page.

    Otherwise you will need to use javascript to find the element (document.getElementById('elementId') if it's a regular html control or document.getElementById('<%=elementId.ClientId%>') if it's a control with a runat property), and then add an onclick effect to it.  You can either do this in the code-behind file or, if you're using jquery, by using the $document.ready(function{}) javascript function (which is automatically called when the page loads).

    You have a number of options on how to bind the onclick event, so just let me know which you feel most comfortable with and I can try to point you in the right direction.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, September 20, 2009 11:26 PM