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
I ended up using a datagrid control.
HTML
Code Behind
JavaScript