How to set properties from content pages to master pages

My naviagation controls are created on the master page with home button image set to visible=false. On all of my pages except the default.aspx page I want to set it to visible=true. When I try to script this on the masterpage I'm not sure how to keep my string in scope. I thought I could just set a string imagebutton1on and set this to on.

On the child page I was trying


partial class Resume : System.Web.UI.Page


string Imagebuttonone;

protected void Page_Load(object sender, EventArgs e)


Imagebuttonone =




On the master page I was trying some logic


(imagebutttonon= "on")

ImageButton1.visible =



ImageButton1.visible =



5/14/2006 4:46:58 AM 13714 articles. 0 followers. Follow

4 Replies

Similar Articles

[PageSpeed] 8

What is it you are trying to do, exactly? Sounds like you should be using something like bread crumbs or perhaps a multiview. Have you tried fully qualifying the button? Something like MasterPageForm.HomeButton.Visible = false (I'm not sure if this is the right "format" but it's something like that -- you may have to use a findcontrol on it). You would not do this in the master page, however, but in the content pages that utilize the master page.


5/14/2006 6:41:25 AM

I'm trying to make a control visible from a content page when the control is actually located on the masterpage.


I tried this fhe content page that is calling the masterpage

protected void Page_Load(object sender, EventArgs e)


MasterPage.ImageButton1.Visible = true;


The error that comes back is.

CS0122: 'MasterPage.ImageButton1' is inaccessible due to its protection level


5/14/2006 6:57:53 AM

Yep, you're probably right. I don't think you can change the master page settings at that point. Try in the Page_PreInit. I think you can only mess around with the master page stuff before the page is rendered.


5/14/2006 7:05:00 AM

Thanks for the help Randy, you put me in the right direction.

I did find some code that worked on MSDN,

ImageButton ImageButton1 = (ImageButton)Master.FindControl("ImageButton1");

if (ImageButton1 != null)


ImageButton1.Visible =




5/14/2006 7:39:34 PM

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

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

Value of the control at Master page is not being set from the content page
I am trying to set the value of the control at Master Page from the child page(content page) but the value of the control at master page is not changing.."Hope its your Solution so Mark it as Answer"Ahmad SheikhMicrosoft Valuable Geek Here is a good tutorial on doing this from scott. here is the part you are looking for I think. Protected Sub Page_Load(ByVal sender As Object, _                     &...

Programmatically set a content pages Master page to another Master page which is nested in the original
Hello, I have a set up where I have a main masterpage that I use most of the time but occasionally I need to swtch to another masterpage which is actually nested to the main masterpage. The switch needs to happen between postbacks from one content page to another. The problem I'm having, is that it is giving me an exception that it cannot find the content place holders in in the main master page. I have overriden the OnPreInit event of the content page where I check a session variable to see if I need to load the nested page or the main page. When I try to load the page I am presented ...

Best way for content page to set a property on its master page?
I'm confused by all the different options.. what is the best way for content page to set a property on its master page?  For example, I have google ads displayed by the master page, but I want the content page to set a variable to indicate the google channel for the ads on that page. Hey,Each content page has a MasterPage property, which you can convert to your appropriate master page type.Brian"Trust in the Lord and do what is good; dwell in the land and live securely. Take delight in the Lord, and He will give you your heart's desires" (Psalm 37: 3-4)....

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

Referencing a user control property in a master page to set the current pages title
How can I Reference a user control's property in a master page to set the current pages title?Jeff Wasilauski, MCAD .NET, MCPC# WEB DEVELOPMENT-SQL SERVER DBA"If I have answered your question please mark as answer" You can drag and drop a user control named userControl1 to master page and refer to its property through userControl1.Title to set master page title in Page_Load event handler. Thanks for your reply Jason but perhaps I wasn't completely clear about the functionality I need. I need to set the content page's title in the user control which is...

setting a controls properties within a master page from aspx page without code behind
I have a custom header control that has a public property TabID declared in the codebehind of the control itself. In asp1.1, I dragged the header control to a page and set the tabid like: <uc1:myheader runat="server" TabID="1" /> inside the aspx page it was placed. Now I would like to put the header control inside a master page, but I'm not sure how to set this property without setting it in codebehind for every page i create.  Is this possible? What is the best way to get this value to the header control as it is different for every page?...

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

synchronizing content pages to master page when master page is edited
 Hi Guys,I'm new to designing websites so please forgive this basic question.I've updated my master page and the modfications ( adding a couple of extra place holders)  are not reflecting in the content pages.Is there any way we can update the content pages created before the changes to the master page were made.Thanks a lot  :)  abhinaynag: I'm new to designing websites so please forgive this basic question. I've updated my master page and the modfications ( adding a couple of extra place holders)  are not reflecting in the content pages. Is t...

convertion from page to content page or from user control to content page
Hi, I have converted an 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...

Web resources about - How to set properties from content pages to master pages -

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.

Fluffy buyback extended to neighbouring properties that share a wall
... Fluffy buyback and demolition Chief Minister Andrew Barr extended the Fluffy buyback and demolition scheme on Tuesday to include some properties ...

Smart Buys: Sydney properties for less than $1 million
Domain's choice of smart Sydney properties this week.

One missing as bushfire threatens properties north of Lancefield, central Victoria
UPDATE: AN elderly man is missing as crews work to protect rural properties under threat from a 3000ha bushfire that continues to burn out of ...

Golden Mile a 'basketcase' as commercial properties lose value
Kings Cross will never again function as Sydney's late-night entertainment precinct, property owners say, with residential developers snapping ...

Queensland storms: Roofs ripped off houses in Warwick, 19,000 properties left without power
... roofs in Warwick, as wild storms move across south-east Queensland. More than a dozen homes have lost their roofs and close to 19,000 properties ...

Resources last updated: 11/29/2015 4:41:47 PM