Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Menu Control and Javascript 1

Status
Not open for further replies.

checkai

Programmer
Joined
Jan 17, 2003
Messages
1,629
Location
US
I want a menu item to execute a javascript function on the page that is is loaded. Cannot get this to work so far. The menu is in a Master Page

"...your mom goes to college..."
 
What type of menu? What javascript function? What do you have so far and what errors are you getting?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
an asp:Menu control in .net 2.0.

I want a menu item to simply display a DIV tag on the page with javascript.

I have tried setting the navigateURL = "javascript: functionName()", but that does not work.

"...your mom goes to college..."
 
This worked fine for me:
Code:
<asp:MenuItem Text="test" NavigateUrl="javascript: alert('hello');"></asp:MenuItem>


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Thanks! I had tried putting that in the sitemap file, but didn't work. When I put it in the MenuItemDataBound it works.

Code:
 Protected Sub mnu_MenuItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles mnu.MenuItemDataBound
    If e.Item.Text = "Client View" Then
      e.Item.Enabled = False
    ElseIf e.Item.Text = "Admin" Then
      e.Item.NavigateUrl = "javascript: showDiv();"
    End If
  End Sub

"...your mom goes to college..."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top