how to work with master page content from content page

 Hi

i make a master page and put a menu on it.

then i add a content page from the previous master now i want to work with the menu of the master page from the content page (no intelisence present !)

 any idea?

 
thanks in advnace.

 

0
seco
2/3/2008 11:03:24 AM
asp.net.navigation-controls 13714 articles. 0 followers. Follow

2 Replies
1074 Views

Similar Articles

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

Hi,

Well you have to go something like this.

ControlType obj = ((ControlType)this.Master.FindControl["ControlIDonMasterPage"]);

once you cast the control into the correct type then you can use obj to play around with the control on the masterpage.


Faraz Shah Khan
MCP, MCAD.Net, MCSD.Net, MCTS-Win/Web, MCPD-Web
Blog
0
farazsk11
2/3/2008 2:33:00 PM

Hi,

seco:
now i want to work with the menu of the master page from the content page (no intelisence present !)

You can try to export the menu control as a public property in the master page's codebehind, then you can access it in the content page's codebehind:

1. The export the menu control in the master page codebehind:
 public Menu menu
    {
        get
        {
            return this.Menu1;
        }
    }

2. The mastertype in the content page:

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

3. Access the menu control in the content page's codebehind:
 protected void Page_Load(object sender, EventArgs e)
    {
        Menu menu = this.Master.menu;
        if (menu.SelectedItem != null)
        {

           // getchilder(menu.SelectedItem);
        }
    }

 

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
2/5/2008 7:22:08 AM
Reply:

Similar Artilces:

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...

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...

Show content in both Master Page ContentPlaceholder AND Content Page Content control
I note that by default or rendering rules, when you add content/controls to the Content Page ASP:Content control matched to a Master Page ContentPlaceholder, any content/controls in the matching Master Page ContentPlaceholder is not displayed. Is there a setting that can be made to merge or show both content/controls in the Master Page ContentPlaceholder and content/controls in the matching Content Page Content control? Thanks         Don't think so. If you specify a content control in your page then whatever is in there displays and anything in the...

Problem to use TreeView Control in a 'content page' This Error Occur "Only Content controls are allowed directly in a content page that contains Content controls."
hi I am trying to use the TreeView Control inside the content page (Page that has a master page is a content page). On compiling the project I got the following ASP.Net runtime error: "Only Content controls are allowed directly in a content page that contains Content controls."B@b@R J Issue resolved. I was putting script tag in the content page that is not allowed. when remove the script from content page problem is resolved.B@b@R J...

Content controls are allowed only in content page that references a master page.
HiI'm getting the above error with my application.Basically I had a master file and then some page files referencing the master file.In the page files I had some ajax controls so had :<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"><atlas:ScriptManager ID="ScriptManager1" runat="server"></atlas:ScriptManager>in them.but when I try adding an ajax control to the master file and putting the above code in, it shows the error messagewhy would this be?thanks!  Make sure you have prop...

convertion from page to content page or from user control to content page
Hi, I have converted an asp.net 1.1 application to 2.0.  Now what I am looking for some enhancement.  I added a master page and now I want to add other pages as content pages. but those pages which I am converting into content have some user control. Now either I can convert those user control to content pages ( which i want to look for if it is possible),  Or I am thinking i shouldn't convert those user control to content pages cause they might be just good. So looking for some of those people opinion who have worked through this so can I get opinion here please.thanks&nb...

error: Content controls are allowed only in content page that references a master page.
 I have a website that uses a masterpage. most of my users have no problem; but few get the error bellow. I was never able to duplicate the error.   ex.message: Content controls are allowed only in content page that references a master page.Stack trace:    at System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection)   at System.Web.UI.Page.get_Master()   at System.Web.UI.Page.ApplyMasterPage()   at System.Web.UI.Page.ProcessRequestMain(Boolean in...

Error:Content controls are allowed only in content page that references a master page?!!
 Hello All I have a web application, it is working well in localost without any error but when I upload it to the host it show me the error below:Any suggestion? I have not seen this error beforePlease any helpRegards, Server Error in '/' Application. Content controls are allowed only in content page that references a master page. Description: Anunhandled exception occurred during the execution of the current webrequest. Please review the stack trace for more information about theerror and where it originated in the code. Ex...

Using an Update Panel in a Content page of Master.page/content.page scenario
When I place an Update Panel inside a content page of a Masterpage I get the following error: Element 'UpdatePanel' is not a known element. This can occur if there is a compilation error in the Web site.  Is the Update Panel suppose to work with a content page, etc.?  Can't seem to find any Docs that talk about where the Update Panel is allowed. Warren     Well, don't you know it.  Right after I put out the original post, I then downloaded the latest release of the ajax extensions and it looks like they have fixed the problem with the update panel not working ...

Contents of Master Page doesn't appear in the contents of the Content Page !!
I created the Master Page, & I created the content page as I read in many books & articles: Website>>add new item>>web form>>check the Select master page>>add Then, only the content box appeared. What should I do?? thanks What did you place in your Master page? If you only use a simplest master page with only 1 ContentPlaceHolder and 1 Lable (don't put the Lable inside ContentPlaceHolder), would the Label appear in content page?Welcome to my SQL/ASPNET forum for Chinese http://51up.org/bbs/forumdisplay.php?fid=38 pic. of master &...

CSS not accessable from content page when Master Page and Content Pages are in different folder.
I can't seem to find a solution to this problem.  I have a master page and content pages and a CSS file all in the root folder.  I have created a sub folder called News and have added a content page that references the master page in the root directory with the following: MasterPageFile="~/Default.master". The issue is that the page in the News folder is not picking up the CSS styles from the master page.  Has anybody else ran into a problem like this and was able to find a solution? Any help would be greatly appreciated? Thanks, Neeraj    N...

Master page default content renders instead of content page content PLZ Help
Hi all A simple task: I need to create a masterpage with default content in the single asp:contentplaceholder on this page. And on my content page I want to put some different content in the asp:Content which is linked with the masterpages ph. (I want to override the default content) It worked fine until I added some new content to asp:contentplaceholder. My code Master Page: <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtm...

Having Problem in Posting Value from a Content Page to another Content Page within a Same Master Page
Hello, I have a Master Page which contains two Content pages named: Default.aspx and Default2.aspx. I want to post a TextBox1 value (in Default.aspx) to Default2.aspx in the Master Pages and all my pages are in ContentPlaceHolder, but it is not working.   Is there Any kind of help?  Hi,you can pass value between two web forms by Query string, session  or by using cookieFor query string  refer : http://www.codeproject.com/KB/aspnet/QueryString.aspxSession: save session in default.aspx Session("t1")=text1.text retrieve session astext2.text = session(&quo...

Web resources about - how to work with master page content from content page - asp.net.navigation-controls

Help:Contents - Wikipedia, the free encyclopedia
Templates are special pages that contain boilerplate text intended to be displayed on more than one page in Wikipedia. This Tip of the day box ...

Portal:Contents/Culture and the arts - Wikipedia, the free encyclopedia
The word culture is derived from the Latin root cultura or cultus meaning to "inhabit, cultivate, or honour". In general, culture refers to human ...

Run fuzzy content-aware searches on your PC with AIKIN Desktop Search
... ribbon. On first launch there’s a delay while AIKIN Desktop Search indexes your Outlook emails, tasks, calendar items, file names and contents. ...

Netflix expands its content empire to 130 more countries
Netflix is more determined than ever to rule the world of online video streaming. During its keynote presentation at CES 2016 on Wednesday, Netflix ...

GRAPHIC CONTENT: Massive Bloodshed in Battle to Capture El Chapo
When Mexican authorities moved in to arrest famed drug lord Joaquin “El Chapo” Guzman Loera they were met with heavy resistance by his security ...

It would take 25 days to binge-watch all of the new Netflix original content coming out this year
In a keynote speech at the Consumer Electronics Show (CES) in Las Vegas, Netflix ’s head of content Ted Sarandos announced that Netflix will ...

New patch for Diablo 3 brings loads of new content
Still playing Diablo 3 ? Yay! Brace yourself for a huge patch and an influx of brand new content. Patch 2.4 - which brings a new zone, Greyhollow ...

Sling TV Overhauls Interface, Adds New Content -
Dish this week announced that its over the top streaming service Sling TV will be getting a shiny new interface, as well as some new content. ...

NextVR announces live VR content portal for Qualcomm phones
... now but to access it, you needed to have the right phone, the right app and a Samsung Gear VR headset. Soon, accessing this streaming VR content ...

Oracle Well Positioned To Help CMOs Build Roadmap For Content Marketing
“Content marketing” was one of the top agenda items for the world’s leading CMOs this past year and topic of intense interest at the 2015 Forbes ...

Resources last updated: 1/11/2016 1:42:04 PM