CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 12/20/2006 8:17:19 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 29 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
ureyes84
Asp.Net User
Adding JavaScript to a Menu Item in a Menu Control12/20/2006 8:17:19 PM

0/0

Hi world,

 I have this menu 

<

asp:Menu ID="MenuMain" runat="server" BackColor="#F7F6F3"

DynamicHorizontalOffset="2"

Font-Names="Verdana" Font-Size="0.8em" ForeColor="#7C6F57"

StaticSubMenuIndent="10px" Orientation ="Horizontal" OnMenuItemClick="MenuMain_MenuItemClick" >

 

<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

<DynamicHoverStyle BackColor="#7C6F57" ForeColor="White" />

<DynamicMenuStyle BackColor="#F7F6F3" />

<StaticSelectedStyle BackColor="#5D7B9D" ForeColor="White" />

<DynamicSelectedStyle BackColor="#5D7B9D" />

<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />

<StaticHoverStyle BackColor="#7C6F57" ForeColor="White" />

<Items>

<asp:MenuItem Text="Change User" Value="ChangeUser" ></asp:MenuItem>

<asp:MenuItem Text="User Manual" Value="UserManual" NavigateUrl="~/Documents/FastTrackReadme.pdf" ></asp:MenuItem>

<asp:MenuItem Text="Links" Selectable="False" Value="Links">

<asp:MenuItem Text="WAWF" NavigateUrl="http://wawf.eb.mil" Value="WAWF"></asp:MenuItem>

<asp:MenuItem Text="AFCEE Web" NavigateUrl="http://www.afcee.brooks.af.mil" Value="AFCEE Web"></asp:MenuItem>

<asp:MenuItem Text="Outlook" Value="Outlook"></asp:MenuItem>

</asp:MenuItem>

</Items>

</asp:Menu>

  And I want to add JavaScript in the "ChangeUser" Item (the first item), so when users click on this page, it won't post back to the server and it will execute my function.

 Example:

<asp:MenuItem Text="Change User" Value="ChangeUser"  onclick="MyFunction();"></asp:MenuItem>

But it won't let me add the onclick attribute, nor do something like:

 MenuMain.items[0].Attributes.Add("onclick", "myfunction();");

 

Any ideas how I can attach my function to this menu item?

 

Thanks world.

 

 


--
Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. Luke 11:9
ureyes84
Asp.Net User
Re: Adding JavaScript to a Menu Item in a Menu Control12/20/2006 9:08:19 PM

0/0

Ok world...

 this time you blew me off, so I came up with a quick fix, I know it's ugly but it works :)

 

<asp:MenuItem Text="<span style='cursor:pointer;' onclick='javascript:MyVeryCoolFunction();'>Change User<span>" Selectable="False" Value="ChangeUser"  ></asp:MenuItem>
 

 Thanks again, I would appreciate if you could suggest a better solution, if not, you just learned how to trick the menu control.
 



--
Ask and it will be given to you; seek and you will find; knock and the door will be opened to you. Luke 11:9
2 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Menu control with SiteMapDataSource not firing MenuItemClick ... ... items under menu item 2, the post works ( I can debug through the javascript and ... To add and then data-bind the <asp:menu> control to a <asp: ...
Yahoo! UI Library: Menu Examples: Explore examples of the Menu Control in action. ... An alternative way of adding items when building a Menu from script is to ...
Adding menus to your web pages ... natively support menus, and coding them in JavaScript is a non-trivial matter. ... To add, delete, and modify menu items, click on the Edit menu button. ...
Technical Q&A QA1219: Adding menu separator items to controls in a ... ... Information about using menu-item separators in an NSPopUpButton control of a Sherlock ... I add a menu separator item to an NSPopUpButton control in my ...
YUI Library Examples: Menu Family: Adding A Context Menu To A Table Grouped Menu Items With Titles From JavaScript. Multi-tiered Menu From Markup ... Menu Buttons (included with examples for Button Control) ...
DHTML Menu, DHTML Drop Down Menu, JavaScript DHTML Menu,Sothink DHTML Menu ... big optimized publishing guide you to add a drop down menu to ... to edit and preview menu in the preview window directly; double-click menu item to edit ...
Cutting Edge: Adding a Context Menu to ASP.NET Controls ... an element in the page, some JavaScript fires, moves ... Each menu item consists of a LinkButton control with an internal handler bound to the Click event. ...
Configuring and adding menu items in Eclipse V3.3 In earlier versions of Eclipse, adding commands to a menu, pop-up menu,or toolbar was tricky. ... menu is registered to the site and attached to the control of ...
ASP.NET QuickStart Tutorials ... To accomplish the pop-out behavior the Menu control relies on javascript, on ... items that are declaratively or programmatically added to the control's ...



 
All Times Are GMT