Need to set properties of certain menu items from a content page for a menu that's on the master page.

I would like to set the back ground of my first three menu items to gray when the user selectst the 5, 6, or 7th item.  I can't seem to figure it out, this is what i thought would work but i guess you can only have 1 selected menu item at a time.

Menu menu = Master.FindControl("Menu1") as Menu;

menu.Items[1].Selected = true;

menu.Items[2].Selected = true;

menu.Items[3].Selected = true;

Or is there a way to do it like this but just but not for all the menu items?

menu.StaticMenuItemStyle.BackColor = System.Drawing.Color.Gainsboro;

thanks for any help.

 

 

 

0
jwkeenan
10/23/2007 3:41:37 PM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

1 Replies
1016 Views

Similar Articles

[PageSpeed] 21

Hi,

Base on your description, you want to change the menu's property in the content page, bu the menu control is on the master page, right?

You cna cannot use the findcontrol method to find the master page's menu control, because the menu control will change into some table according to the menuitems.

But you can use propery, that is, declare a public property an return the menu object, then you can access this property in the content page and its property.

For example:

1. Declare a menu poperty in the master page codebehind:

  public Menu menu
    {
        get
        {
            return this.Menu1;
        }
    }

2. Refer the mastertype in the content page:

<%@ Page Language="C#" MasterPageFile="~/TestMasterPage/case/MasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="TestMasterPage_case_Default" Title="Untitled Page"  %>
<%@ MasterType VirtualPath="~/TestMasterPage/case/MasterPage.master" %>

3. Access the menu control in the content page:

 Menu menumenu = this.Master.menu;
        menumenu.StaticMenuItemStyle.BackColor =  System.Drawing.Color.Gainsboro;

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
10/25/2007 5:55:46 AM
Reply:

Similar Artilces:

How to set a Master Page's control's property through content page on a postback event?
Hi all, i m using a master page in my application. i have a panel on master page and a tab container with three tab panels on content page. i want to set/change  the visibility of the panel control when the tab is changed on the content page. By default the panel is invisible. To implement this i executed the following steps: 1. Set AutoPostBack of tacontainer to true 2. Wrote an event handler for ActiveTabIndexChanged event of the tab container 3 Wrote the following code on Tab changed event   if (TabContainerEmpPerformance.ActiveTabIndex == 1) { ...

Setting a property of a nested menu control from it's base ASPX page
Hello, I have 3 ideas at work here. 1. An ASPX Page 2. Header Control (which resides inside the ASPX Page)3. Menu Control (which resides inside the Header control) In the ASPX Page, I create an object which I would like to pass to the Menu Control.  What is the best method to get this object into my Menu Control?  For instance, if my Menu Control looked something like this.... Public Class category_menu Inherits System.Web.UI.UserControlPublic myMenuData As MenuExpanderData Function DesignMenu()End Function End Class ....where MenuExpanderData is simply the data that ...

disable menu items,sub menu items, treeview items,subitems in master page based on certain conditions
Hi, I have a master page,sitemap and a content page. my master page contains menu control and treeview control.when I link master and cotent page then menu and treeview are displayed.Now my problem is,when I run the application I need to disable particular menu item and its child contents,treeview item and its child contents based on certain criteria(based on user roles).Can I do this using javascript or in code behind?If so how?   thanks stev  You should use one of the following two method to find the nodes or items you want to disable from the treeview control ...

How can I access the property a control on a master page from the master page's code behind.
On my master page I have a label. I want to change this label's text property based on an element of the querystring. (label.text = "NewValue")All child pages using this master will display the same thing so I was trying to put the code in the master page so as not to have to duplicate it for the child pages or put it in a base class and use FindControl.Is it possible to access from a master page's codebehind the property of a server control that is placed on a master page's aspx? If so how?(I saw similar questions, but they all came from the view of a child accessing the property.)Thank you...

Content controls have to be top-level controls in a content page or a nested master page that references a master page.
Why in the world am I getting this error? The solutions I have seen either don't apply or don't work.  Here is my master page code:<%@ Master Language="C#" AutoEventWireup="false" CodeFile="TechLMSMasters/MainSide.master.cs" Inherits="MainSide" %> <%@ Register TagPrefix="usercontrol" TagName="Search" Src="~/library/uc/Search.ascx" %> <%@ Register TagPrefix="usercontrol" TagName="UserName" Src="~/library/uc/UserNameDisplay.ascx" %><!DOCTYPE html PUBLI...

Label control's text doesn't appear to be set (in the page which has a user control )when trying to update the text property in the FormView's ItemUpdated event
Hi There,I have a user control which hosts a formview control, gridview control and a label control. The grid view is usedto show rows in the DB and when clicked to edit each row, a form view opens up in edit mode with that particular row info. So I have nothing in the item template.My first question is..is it mandatory to have smth in the itemtemplate of the form view.I have controls in edititemtemplate and insertitemtemplate.When a particular row is edited, I would like to show a status msg showing that the row has been updated.For this, I use the ItemUpdated event of the formview and try ...

TreeView menu in the Master Page
In my ASP.NET2.0 app I have a Master Page with a TreeView menu on it. The problem is - when navigating to another page which uses the same Master Page, the TreeView control does not remember it's own state - collapsed nodes become expanded again, no selected node, etc. I understand that in aspx page ViewState is not getting transferred to another page, but shouldn't be some trick available for Master Pages to remember somehow the state of controls placed on the Master Page?Otherwise it would undermine the idea of Master Pages - I can't use a menu if it can't remember it's stat...

ERROR Content controls have to be top-level controls in a content page or a nested master page that references a master page.
This all used to work until about 5 minutes ago. Did I change something? For some reason I am now getting this error: Content controls have to be top-level controls in a content page or a nested master page that references a master page. What I have:  I have a masterpage inside of a directory. That directory is a first level directory with its own web.config file....The whole thing is protected by the web.config file above it (in the main public directory). That main public directory has a masterpage as well. I am not currently linking the two masterpages together becuase...

Error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.
when I make a directory on my root, and in that directory I put a masterpage and a web form ... I get always an error : Content controls have to be top-level controls in a content page or a nested master page that references a master page.   Does somebody know what the problem is ? Is it possible you can't set a masterpage in a directory ... ?Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) i've founded ... I had to nest my masterpage ...Kind Regards,Joeri Pansaerts.From Bruges, Belgium :) Hi Joeri Pansaerts, I am receiving the same error as the one posted her...

displaying a gridview in content page from master page menu control !!!
Hi i need a help for this problem ...                 I have a menu control on my master page which is dynamic (ie  the menu is designed from the SQL ) then i want to populate a grid view based on the selection made on the menu control .Hope i explained clearly .   Hi cindrella, You can use event MenuItemClick to find out what has been clicked on the menu. But menu control in ASP.NET 2.0 has problem that if you specify NavigateUrl property then it wont fire MenuItemClick eve...

Displaying a gridview in the content page from the menu control in the master page !!!
 I have a menu control in the master page .I want to display a Gridview in my content page based on the selection made in the menu control . Please help me out !!!   hi!1. Define some interface:public interface ISample{    void doAction(string action);}2. Implement it in content page:public partial class Default2 : System.Web.UI.Page, ISample{    public void doAction(string action)    {        GridView1.Caption = action;    }}  3. In master page handle menu click event an...

Doing Postback from master page to page in master's content place holder(search page)
Hi, Currently I am trying to do a postback which returns results. The master page has a textfield and button and the button redirects to the search page.The search page also has a textfield and button and when the button is clicked, the query statements take the input from teh user and looks for results. Currently, A Crosspage postback of master page + other pages in content place holder ------> master page+search page in content place holder works.I am trying to do a postback which returns results in master page+search page which gets its input from the textbox of the master page ...

Master Page
I am using a master page for a website (Vs 2008) . I am facing two problems - 1. In the Login page, I am hiding the logout hyperlink. After the user logs in successfully , I'm setting the visibility of the logout hyperlink to true. But then, when I navigate to another page, the logout button disappears -  forcing me to redo setting the visibility in every page. 2. I have a similar problem with an Image in the page too. When I change the image in the content page after login, it reverts back to the existing image in the master page ( this I guess is because the master page loads...

how to access menu item selected in master page from within a content page
I' am a newbie using VS I need to change a propertie of a DetaisView in a content page depending on the selected item in the menu control located in a master page how can I access the value of the selected menu item in the master page and than change the DetailsView property "Visible" to True o False depening from the menu item selected   thanks in advanc try this  CType(Master.FindControl("Menu1"), menu).Items.IndexOf(e.Item)HAPPY CODINGhttp://shobhitrai.blogspot.com/ tanks but  it doesnt work yet  The following message showed up Na...

Web resources about - Need to set properties of certain menu items from a content page for a menu that's on the master page. - asp.net.navigation-controls

General Growth Properties - Wikipedia, the free encyclopedia
Chicago , Illinois , U.S. General Growth Properties, Inc. is an American real estate investment trust , headquartered at 110 North Wacker Drive ...

RentalRoost Brings Facebook Into Process Of Matching Up Home Seekers, Available Properties
... places to live , as RentalRoost , a San Francisco Bay-area-based website that incorporates Facebook data into its rankings of available properties, ...

Extended Profile Properties - Facebook-Entwickler
These Permissions cannot be revoked in the Login Dialog during the login flow, meaning they are non-optional for Users when logging into your ...

PortPerry Properties (@brian14mckinlay) on Twitter
Sign in Sign up To bring you Twitter, we and our partners use cookies on our and other websites. Cookies help personalize Twitter content, tailor ...

Hawaii Real Estate Properties for iPad on the App Store on iTunes
Get Hawaii Real Estate Properties for iPad on the App Store. See screenshots and ratings, and read customer reviews.

Australian Federal Police raid properties in new CFMEU-linked investigation
Federal Police have raided properties as part of an investigation into a CFMEU organiser suspected by authorities of being bribed.

Sydney gateway: Rail line to be moved, properties affected under plan to link WestConnex to airport
A key rail line linking Sydney's west with Port Botany will need to be shifted under tentative plans to build separate motorways to Sydney Airport. ...

Digital detox: Australians seek out nature properties to overcome technology burnout
Holiday home rental companies say they have seen a spike in the number of customers seeking digital detoxes, allowing savvy homeowners to offer ...

InvenTrust Properties Corp. Announces Acquisition of Two High Performing Open Air Shopping Centers
InvenTrust Properties Corp. (&ldquo;InvenTrust&rdquo; or &ldquo;the Company&rdquo;) today announced that it has acquired two high performing ...

CoreLogic: "Number of Mortgaged Properties with Negative Equity Down 20.7% Year Over Year"
From CoreLogic: CoreLogic Reports 256,000 US Properties Regained Equity in the Third Quarter of 2015 CoreLogic ... today released a new analysis ...

Resources last updated: 1/12/2016 9:16:49 AM