Can I call a client side\java script function by clicking a menu item from the menu control?

I would like to use the menu control to populate a listview without the menu causing a postback.  Is there  way to call a javascript function by selecting a menu item.  Thanks for any help.

0
jwkeenan
3/4/2008 6:39:25 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

1 Replies
1661 Views

Similar Articles

[PageSpeed] 58
Get it on Google Play
Get it on Apple App Store

HI,

You can try to use ClientScriptManager..::.RegisterClientScriptBlock Method to call the client script of the page in the menu's MenuItemClick event.

But you shold make sure the menuitems have no navigateUrl, or else the page will redirect to the navigateUrl without postback, so the MenuItemClick  event will not be fired.

About the RegisterClientScriptBlock , you refer this msdn article: http://msdn2.microsoft.com/en-us/library/system.web.ui.clientscriptmanager.registerclientscriptblock.aspx

 

hope it helps.

 


Amanda Wang
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Amanda
3/6/2008 12:10:49 PM
Reply:

Similar Artilces:

Retain state of controls on menu item click (Menu control)
I have a project setup as Master-Content pages. I have also included a Menu control in the master page. I have some textboxes and dropdownlists in content pages. The problem is that when I click any of the menu items, the page gets refreshed instead of doing a postback and all the values of the controls are gone. This creates a problem in a case where user is on one item page, he types in some values, does a postback, gets the results, and then if goes to other item in the menu and comes back, all those values are gone. How can I retain the values of controls (textboxes, dropdownl...

Controlling how many menu items appear in the menu control
Hi I have a menu control which is bound to the web.sitemap. I want to be able to control how many static menu items can be displayed in the menu. I have the home button showing with other buttons too i.e. staticdisplaylevels=2. But how do I say for example to only show the first 6 main sitemap nodes to go in the menu so that there are only 6 menu items to chose from even though there are more defined in the sitemap. Thanks in advance. You can use the MenuItemDataBound event and hide the menu's you don't want to show to the user Alternatively you can add a custom attribute (visible="false"...

image by side of menu item in menu control
I would like to add an image by the side of the my item in menu control. Is it programatically possible?    any help! I am using this menu control in the master page. I would like to prefix an image to the text of the menu item. inkrajesh:I would like to add an image by the side of the my item in menu control. Is it programatically possible?  Based on my experience, the MenuItem has a ImageUrl property, you can set image url to it to solve your problem, to know more, please check this link,  http://msdn.microsoft.com/en-us/library/syste...

How to control the client script position generated by Menu control?
I used the asp.net 2.0 menu control, and the submenu popup javascript is generated by menu control automatically. But the javascript is located at the bottom of the whole page, so the popup behavior will not be available until the whole page is loaded. How to control the js postion? I wanna make it at the top the page. Any suggestion will be appreciated. no one knows thie problem?...

how to show the first menu item as the selected menu item in a "Menu control"
Hello Mate,    i have made a tab control using the menu control and the multi view control. all i need is, how can i show the first menu has been selected when my web page got run.   thanks in advance,Myself  Much Obliged & Thanks a Lot,Myself Sidewinder2: i have made a tab control using the menu control and the multi view control. all i need is, how can i show the first menu has been selected when my web page got run. Hi Sidewinder2, Why not use the Tabs control?  Also you can refer this link to solve your problem, http://www.getdotnetcode.com/...

Removing a menu item for the menu item control
In a menu control I have several items In the Menu1_Load event I want to conditionally remove a menu item.I use the codeMenu1.Items.RemoveAt(4). How do I test for the existence in the menu item at index 4 before removing it??Thanks Hi, You can compare Menu1.Items[4].Text against the title of the node. Yes but if it was removed earlier then the code will error out. So I need to test for the existence of Menu1.Items(4). If it exists then remove it. craigbtx: In a menu control I have several items In the Menu1_Load event I want to conditionally remove a menu item.I use the codeMe...

Menu Control
Hi everyone, Im developing an application in Asp.net 2.0 by using menu control (in a user control).In which each menu item navigates to a new page. Now i want to apply different setting(For eg. Changes Forecolor) of selected Menu Item but the problem im facing is whenever i navigate to the new page the user control is reloaded and im unable to get the selected menu item. I can't use session or viewstate in my application. Thank u. Are you using MasterPage? If you put Menu control into the MasterPage and if the two content page you switches are both create from the same MasterPage,...

menu control
HI I am trying to set the styles for an asp.net menu control and it's just not happening. I am trying to set the style for a static menu item to be a background image so I have this code for the menu: <asp:Menu ID="MainMenu" runat="server" Orientation="Horizontal">         <DataBindings>            <asp:MenuItemBinding DataMember="siteMapNode"              TextField="title" NavigateUrlField="url"  />   &n...

How can I call a javascript function on a MenuItem of the Menu Control ?
I wish I had something like OnClientClick for each Menu Item, but it aint such event  Only OnMenuItemClick, but thats a server side event.  Is there a way to do that ?  Thanks !     SkynyrdL. SkynyrdPlease, mark as answer when appropriate Hi Skynyrd, You could use the DynamicItemTemplate of the menu control, for eaxmple like below:<asp:Menu ID="Menu2" runat="server" DataSourceID="SiteMapDataSource1"> <StaticSelectedStyle BackColor="#FFC0FF" BorderColor="Lime" ForeColor="...

Java script cannot differentiate client side controls in user control used multiple on same webform
I have a textbox with a automcomplete extender and a client side link that, when clicked, changes style.display from "none" to "" to display a div that contains a listview with all possible choices for the text box.  I am using javascript to change the div style.display when the link is clicked.  When I have two instances of the usercontrol on the same webform, both links display the div on the first control.  How can the client side javascript tell the difference between the two divs? Try putting the javascript of the user c...

Menu control
Hello everybody, I have the above problem. I have a menu on my master page that has four links. One of this links I want to be displayed only when the user is authenticated ( when the user is anonymous only 3 links should appear in the menu).  So, when the user is authenticated I tried to write something but it doesn't work. Here is the code: If User.Identity.IsAuthenticated ThenDim mymenu As New Menu mymenu = FindControl("menua") If Not IsNothing(mymenu) Then mymenu.Visible = False End If    The problem is that first I cannot find the way to make u...

Button image for each top level menu item
For the subpage items I am just going to use background images/styles, but for the top level menu items, I have a button for each one. Just to complicate matters I have a rollover image for each, so when the user's mouse hovers over a given menu item, the button swaps out so they see a different color. Can I do images for the top level menu items? Are rollovers possible as well? How? Appreciate any input. I'm still trying to figure this one out. Has anyone used buttons for their top level menu items? If you could copy the info from your web.sitemap + the css file that would be most help...

Menu control menu items horizontally
how to show the menu items side by side horizontally when mouseover to  root Item in menu control, as we can set the orientation as horizontal in <asp:Menu></asp:Menu>,but how can we set the Orientation as horizontal to menu items <asp:MenuItem></asp:MenuItem>   example like About Us (Main Menu) login listings(these two options "login and listings" should displayed horizontall when mouseover on About Us link) its very urgent   Azam check Below url is it your looking.  http://quickstarts.asp.net/QuickSta...

Menu control-highlight menu item
Hi, I have a menu control. If the user clicks for example menu item New user  and he is redirected to Default.aspx then i want the item New user   to be highlighted. I want the items of the menu to be highlighted according to what page the user is on.  <asp:menu id="NavigationMenu" runat="Server" staticdisplaylevels="2" orientation="Horizontal" width="100%" cssclass="font" backcolor="#B5C7DE" font-bold="True" font-names="Verdana" font-size="0.9em" font-strikeout="False" forecolor="#284E98" height="34px" dynamichorizontaloffset="2" staticsubmenuindent="10px"> <items > <asp:menuitem navigateurl="~/Default.aspx" text="New user" value="New user" ></asp:menuitem> <asp:menuitem navigateurl="~/UnAssigned.aspx" text="Assigned" value="Assigned"> </asp:menuitem>   </items>   <staticmenustyle verticalpadding="2px" backcolor="SkyBlue" /> <staticmenuitemstyle font-names="Verdana" horizontalpadding="5px" verticalpadding="2px" backcolor="Transparent" /> <staticselectedstyle font-bold="True" forecolor="#990000" backcolor="#507CD1" /> <dynamicselectedstyle backcolor="#507CD1" /> <dynamichoverstyle backcolor="#284E98" forecolor="White" /> <dynamicmenustyle backcolor="#B5C7DE" /> <dynamicmenuitemstyle horizontalpadding="5px" verticalpadding="2px" /> <statichoverstyle backcolor="#284E98" forecolor="White" /> </asp:menu> Hi, The MenuItem is already...

Hideing menu item in menu control
Hai all in my application i am using Menu control.I am binding this menu with xml.i need to hide some of the menu in my menu control based on one flag in my xml string.From database i am taking that flag as a xml attribute in the same xml which i use to bind the menu.Plse Help meThanks in advanceLijo Rajan   hi , i dnt know how you maintain flags by using xml attributes, but i have found a good solution for creating dynamic menu by using menu control. http://aspalliance.com/822 go through this link, it may help you  Please: Don't forget to click "Mark as Answe...

How do you control the menu control?
I am using the ASP 2.0 menu control.  When my submenus display, they display on top of the text that is already there from the content page.  The result is an unreadable mixture of text from both the page and the submenu.  Is there a way to force the submenu text to be on top of the content page's text without showing the content page text?  I don't see a property that can do this.  Thanks. The pop out panels should not be transparent and they should appear on top of the content page (unless the z-index of your controls are greater than 1). Please could you pr...

The menu control is out of my control
Here's my situation, I've been searching for about 2 weeks to try to do this without any luck. My limited knowledge of ASP doesn't help but I should have found an answer by now because it seems so simple. So here it is. I'm using the menu control and the CSS Friendly Control Adapters 2.0 to make it a bit easier to apply CSS to. ShowStartingNode is set to false because I want to see the whole menu. I have the menu just how I want it. Now, I want to be able to hide certain nodes in the menu. Not so users cant access them (some people have suggested using access control but this...

Adding menu items dynamically to menu control
if (Page.Form.Parent != null) {Menu omenu = (Menu) Page.Form.Parent.FindControl("RadMenu1");RadMenuItem item1 = new RadMenuItem();  item1.Text = "Item 1"; omenu.Items.Add(item1);   }   The above code segment gives a compilation error - the type or namespace "RadMenuItem" could not be found. Does anyone know The Telerik menu control and how to do this?  Thanks,  Dave     You probably just need to include the namespace at the top of the page. Eg: using Telerik.RadControls; I'm not sure what the actual namesp...

Menu control keep menu item selected
Hi Everyone, I've been using the menu control for navigation within my application using the web.sitemap, everything works fine except when I click on a hyperlink within the page, the selected menu item within the menu control is no longer selected. Is there a way to keep the menu item selected even though I click on a hyperlink within the page? Not sure if this is a good solution, but I was thinking to store the current node within a viewstate and then retrieve on the nect page load (not sure if this will owrk, it's just a theory). Thanks, IJ   IJ,   Since you are clickin...

Adding JavaScript to a Menu Item in a Menu Control
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...

Dynamically adding menu items to a menu control
I want to dynamically add menu items to a menu control depending on certain conditions (I'm using it to mock a tab control)Heres the code: public class TabControl : UserControl{    /// <summary>    /// The menu control represents the tabs themselves    /// </summary>    public Menu menu;    /// <summary>    /// The multiview control represents the data inside the tabs    /// </summary>    public MultiView multiView;    public TabContro...

Menu Control: Adding pipes (|) in between menu items...?
I was just wondering if it was possible to insert pipes in my main (top level) menu items. Something like shown below: Home | Forums | Blogs | Respository | Search But I don't want these pipes to appear in the beginning or the end. I am not binding the menu to any datasource...programming blog I played around with a couple of ideas here.  Of course, I created a horizontal menu with static items.  Then in the designer, I tried to convert the items to a "static item template".  Within this, I added a '|' character after the text, but this still showed u...

Problem with menu control: Spaces in menu item
 Hi,    I am working with menu control. I have the menu items(horizontal menu) with me and some of them will be dynamically generated or removed. I am able to do that but i cant get proper format of the menu items. I mean i want to increase spaces between items in drop down(vertical space) and size of the drop down menu item and also improve their presentation. Can i use the background of the drop down as a table. May be then it will be easy for me to add styles.   You can use the DynamicMenuItemStyle for this: <DynamicMenuItemStyle VerticalPadding="1...

Menu Control: which item clicked?
I want to use the menu control to have several buttons on top of my website.How do I determine which menu item was clicked?please mark answers as 'Answered' and post back solutions when you figure stuff out that isnt in the post already.  Peter Smith wrote:I want to use the menu control to have several buttons on top of my website.How do I determine which menu item was clicked? Can you be more specific?  What "menu" control?  A third party menu control?  If so, which one?  Is it one that you made yourself?  Where's the code?"I would love to change...

Web resources about - Can I call a client side\java script function by clicking a menu item from the menu control? - asp.net.navigation-controls

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

Resource sector may outsource finance functions to Asia
Outsourcing financial functions to Asia is one tactic struggling Australian energy and resources companies may use this year to survive the slump ...

Using Functions to Make Better Abstractions
... (code that is tightly coupled to its own implementation details). I was wrong. I was wrong because I had an incomplete understanding of functions. ...

Media devices sold to feds have hidden backdoor with sniffing functions
... AMX NX-1200 , a programmable device used to control AV and building systems. The researchers first became suspicious after encountering a function ...

A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003
**[A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003](http://www.j-bradford-delong.net/movable_type/2 ...

Drop Point Knives: Function, Fit, Timeless
Drop Point Knives: Function, Fit, Timeless

Here's how squads and iron sights will function in Rising Storm 2: Vietnam
... roles and create a squad, and the creator can name, lock, or invite others to their little group. The more an outfit fills up, the more functions ...

Yahoo Begins Grim Job of Closing Functions, Laying Off Staff
Yahoo Food is closing, and other digital magazines on tech, travel and beauty are also scheduled for closing or major cutbacks.

Don’t tase me, bro: Study shows being shocked by a Taser disrupts brain function
Researchers at Drexel shot a bunch of college students with 50,000 volts. The result? Short-term declines in cognitive function comparable with ...

How The U.S. Supreme Court Will Function Without Justice Scalia
... but in a fashion that could have frustrating ramifications for a number of major cases set to be decided. Here's how the court will function, ...

Resources last updated: 2/18/2016 6:46:37 PM