Master Page - Issue with setting control properties in content 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 after the content page is loaded? )

What am I missing here? Why does it disappear ? How do i fix it such tat once I change the logout button visibility / image it remains as such?



8/18/2008 10:46:24 AM 13714 articles. 0 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 30

Hello Zumbre,
This is a very common situation for user login and logout. What you need to do is to make Master and content page talk to each other in some way. Here you need to store one variable in session, lets say "Authenticated". That is a boolean varible. So for all those users who have sucessfully logged in or authenticated. Store "Authenticated" in session with its value true. LIke this -

1    /// Once user is authenticated
2    /// 
3    Session.Add("Authenticated", true);
Now in your master page load or init. Set the visibility of that login or logout link like this -
1    bool Auhenticated = Session["Authenticated"] as bool;
3    if (Auhenticated)
4    {
5    	/// Set visibility of your controls here
6    }
I hope you are getting what I want to convey.
Thank You,



8/18/2008 11:44:19 AM

hi shail,

Thanks for ur suggestion. Logout seems to work like u suggested.

However, the image problem still exists. Any thoughts on that?

8/18/2008 2:36:16 PM

actually.. it is working.. i overlooked something, forgot to set the image path in the session  Stick out tongue

8/18/2008 2:47:43 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.
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...

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

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, _                     &...

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

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

Need to access a Label Control on the Master Page from a user control attached to a content page
Hello all, I have a master page (say  site.master)  with a status Label in it. I have a content page ( say content.aspx)  that has a user control (say usercontrol.ascx). One of the Button Click Events in the usercontrol.ascx needs to pass on some text onto the status label on the masterpage(LabelStatusMsg) and display it. I have been able to do this directly off a content page (content.aspx) by using the following code (VB)  on the master page <%@ MasterType virtualpath="~/site.master" %> and Dim mpLabel As Label = CType(Master.FindControl("LabelStatusMsg"),...

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

Set the property of a server control inside a user control inside a Master Page
How do you set the property(ForeColor) of a server control(lnkInquiryReport2) located in a user control (LeftNavMain1) within a Master Page (default.master)? On the user control, expose a property of type color and bind this to the forecolor for the hyperlink control [keep some default value]. On your master page expose the user control as a property. On your content page, access the uc via the master's prop and the forecolor prop via the uc's prop and set it. Instead of exposing the uc from the master, you can also find the uc on the master - cast it to the correct type and then access th...

Control of the page and the controls on a page
I am building a web app that has some pages that are public and some that are only available based on subscription. Could someone explain the best way (infrastructure wise) how to control whether a server control is visible or enabledand how to control whether a page is viewable or not based on the user and whether or not the user is logged in (or not). If a user is not logged in I would like some controls to be visible but disabled. I also have to control the URL's in case a person learnsthe URL and tries to type it in. My question is more towards how to do this database wise. I am u...

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

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

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

Using controls from pages, master pages, and user controls
How would I structure my site in this scenario: I'd like to use a dropdownlist all over my site, sometimes in a regular page, sometimes in a master page, and sometimes in a user control.  I wish to bind its events programmatically, so normally I would just put that in the codebehind.  However, I notice a lot of code duplication because I have to declare the control in everywhere, in my base page (which all my pages inherit from), in my base master page (which all my master pages inherit from) and in my base user control (which all my user controls inherit from).How should I be...

Web resources about - Master Page - Issue with setting control properties in content page -

Properties of water - Wikipedia, the free encyclopedia
This article is about the physical and chemical properties of pure water. For general discussion and its distribution and importance in life, ...

Facebook Surpasses All Google Properties In Brazil
Facebook overtook Orkut to became Brazil’s top social network in January, but has only overtaken all of Google’s properties in that nation just ...

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 on the App Store on iTunes
Get Hawaii Real Estate Properties on the App Store. See screenshots and ratings, and read customer reviews.

32 properties resumed to start Kingsford Smith Drive widening project
Hundreds of residents and businesses along Kingsford Smith Drive &ndash; one of Brisbane's busiest roads &ndash; are about to feel the pressure ...

Properties pass in as 1000 auctions unfold after last week’s Melbourne Cup lull
Melbourne's declining real estate clearance rate was reflected by mixed auction results on Saturday.

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

Lancefield bushfire: Home destroyed, properties under threat as bushfire burns in central Victoria
... in a fire burning out of control near Lancefield in central Victoria, the Country Fire Authority (CFA) says, warning that other homes and properties ...

Resources last updated: 11/29/2015 2:43:12 PM