Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:16:03+00:00 2026-06-12T18:16:03+00:00

How do you add a mouseover javascript function to an asp.net menu item when

  • 0

How do you add a mouseover javascript function to an asp.net menu item when the menu items are created dynamically? Doesn’t allow you to add .attributes function.

[Javasript]

<script type="text/javascript">
    function ChangeProjectImage(obj) {
        var ctrl = document.getElementById(obj.id);
        ...code...
    }
</script>

[HTML – Menu Control]

<asp:Menu ID="Menu1" runat="server" Orientation="Vertical" Font-Names="Verdana" Font-Size="12px"
        CssClass="Menu">
</asp:Menu>

[CodeBehind – Add menu items dynamically]

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Me.IsPostBack Then

    Else
        Dim dt As DataTable = Session("dt")

        For Each dr As DataRow In dt.Rows
            Dim mi As New MenuItem(dr(0), dr(1), "images\folder_03.png")
            Menu1.Items.Add(mi)
        Next

    End If
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:16:04+00:00Added an answer on June 12, 2026 at 6:16 pm

    I ended up using a datagrid control.

    HTML

    <div style="clear: left; padding-right: 5px;">
          <asp:GridView ID="GridView1" runat="server" ShowHeader="False" GridLines="None"  BorderStyle="None" CssClass="MyGridView">
              <Columns>
                  <asp:ImageField>
                      <ItemStyle Height="16px" Width="16px" />
                  </asp:ImageField>
              </Columns>
          </asp:GridView>
     </div>
    

    Code Behind

     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Me.IsPostBack Then
    
        Else
            ...code to fill datagrid
    
            For Each gr As GridViewRow In GridView1.Rows
                ...code
                gr.Attributes.Add("onmouseover", "ChangeProjectImage(""productimages/" & gr.Cells(2).Text & """,""" & gr.Cells(3).Text & """)")
                gr.Attributes.Add("onmouseout", "ChangeProjectImage(""images/display2.png"",""140"")")
            Next        
         End If
    
    End Sub
    

    JavaScript

      function ChangeProjectImage(imgpath, resizeheight) {
         var img1 = document.getElementById"MainContent_LeftTopTabContainer_ThumbTabPanel_Image2")
         img1.style.height = resizeheight
         img1.src = imgpath;
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I add event handler to a some elements using query: $('div').mouseover(function () {
I have a CSS mouseover slider fully functional here http://jsfiddle.net/gU4sw/13/ . When I add
I use this simple script : <body> <script type=text/javascript> function mouseOver() { document.getElementById(img1).src =images/p2.jpg;
How can I make a mouseover function in JavaScript less resource-intensive? I used a
I have this jquery code. //this is the main javascript $(document).ready(function(){ $('nav.menu a').hover( function
GMaps v3 Markers AddListener Problem I'm trying to add mouseover/mouseout event listener to my
I wish to add the mouseover events to a panel which contains more than
work on asp.net vs05.i want to set mouse event on gridview Then based on
<html> <head> <title>FML</title> <script type="text/javascript"> function function1(e, div) { div.innerHTML="this works" document.getElementById('myspan').innerHTML= 'x-pos on
I'm trying to add personal text to mouseover inside fullcalendar. The script below works

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.