Error finding the user control in master page from content page


I have a master page in which i have created a header which is a user control into which contains a label.  I a accessing this label from content page.  The code for the following is mentioned below.  Sometimes it works perfectly fine however sometimes it throws object reference error.  So my application is not stable.   Any suggestions what could be the possible issue???????

    Utils UT = new Utils();
    protected void Page_Load(object sender, EventArgs e)
      System.Web.UI.UserControl header = (UserControl)Master.FindControl("hdPocket");
      LinkButton Link = header.FindControl("lnkLogout") as LinkButton;
      Link.Visible = true;
      string store = User.Identity.Name;
      if (store == null)
      if (store == "" && header!=null)
        Label label = header.FindControl("lblGuest") as Label;
        label.Text = "Guest";
        Link.Visible = false;
        Label label = header.FindControl("lblGuest") as Label;
        Regex r = new Regex("@");
        String[] str = new string[2];
        str = r.Split(store);
        label.Text = str[0];  

3/30/2009 1:21:18 PM 13714 articles. 0 followers. Follow

1 Replies

Similar Articles

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

Please check this link first, and please check this paragraph:
You can specify default content placed within the ContentPlaceHolder control tags, but this content is replaced by any content in an associated content page.
So that mean we can not find and controls if we change the content in an associated content page.
Hong-Gang Chen
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
4/2/2009 9:14:46 AM

Similar Artilces:

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

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

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

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"),...

How to do post back in a dynamically created user control [provided that update panel is in the master page of the page where user control is added] {B/C of FileUpload Control}
I have a register my scriptmanager and place the update panel around contenttempalte for my pages int the master page. Now in one of my pages i am adding some user controls dynamically. In two of my user user controls I have FileUpload control which will not work under partial post back. So I want's full postback for them How could I do that {Provided that i am on the user control,which is inside the page ,and page have the contenttemplat...

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

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

find content page control from master page
Pls help me out this one I am using a Master page and a lot of content pages. and i am using timer controls in various pages of my project.... All i need is i want to stop a timer control of a particular page by its id.. i just wrote code in javascript in masterpage asfunction starttimer()   {$get('Timer1').control._startTimer(); } function stoptimer() {$get('Timer1').control._stopTimer(); }   It doesn't work for me.. how to find the control from master page... Thanks in advance This link might help you out,

Master Page , User Control,Content page
 Hi friend ,I have user control at master page, I want to access it's property using content page I have done code but getting problem in deployment.((ASP.usercontrols_travel_hotel_directory_ascx)Master.FindControl("ucHotel_Directory")).Visible = false;  But I am getting following error in deployment project Error    137    The type or namespace name 'usercontrols_travel_animation_ascx' does not exist in the namespace 'ASP' (are you missing an assembly reference?)    d:\By Shakti5385\EternalMewar\Eterna...

Master page - Content page
I have a user control in the Master Page and another user control in the content page. I have to do something in the content page user control according to the actions in the master page user control. I don't know how to achieve it. Please help  If this post was useful to you, please mark it as answer.ClientSideAsp.Net | Blog Create an event in the master page. Raise the event when the user control in master page has that action. Now handle this event in the content page and in the event do what you want to in the content page's user control.  Vikram www.vikramlakhotia.c...

How to over write a user control in master page from content page?
Pals, I tried to access a usercontrol in master page from content page but in vain.. For ordinary pages we are able to access the usercontrol using this line. uclAddlInformation is the user control i am using in the ab.aspx.. Label lblh = (Label)uclAddlInformation.FindControl("LblEquipments"); It doesnt work with master pages..Anybody tried this? first find the control  (air coded);         ContentPlaceHolder content;        Label label;         UserC...

Web resources about - Error finding the user control in master page from content page -

Finding - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

Facebook’s Mike Schroepfer, Jocelyn Goldfein Discuss Challenges Of Finding Female Engineers
Facebook Chief Technology Officer Mike Schroepfer and Director of Engineering Jocelyn Goldfein discussed the social network’s efforts to recruit ...

Finding Simplicity in a Multi-Device World
A new study looks at how people use different devices throughout the day.

Finding App Links with the Facebook Index API
This page describes how to use Facebook's Index API to find App Link data.

American Airlines Calls on Facebook Users to Name New Fare-Finding App
American Airlines is launching a campaign on Facebook to promote its new fare-finding application, which allows users to search for low fares. ...

Finding Carter (@finding_carter) 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 ...

Finding A Perfect Match - Twitter Blogs
Last month, Twitter had a very special date in New York City. We met with another startup, had lunch at the famous Shake Shack, and spent some ...

Uncage the Soul’s “Finding Portland”
"Finding Portland" video Uncage the Soul: “Finding Portland” was produced, shot, and edited in 51 days during March and April. Comprised of ...

Finding Your Passion In Work: 20 Awesome Quotes
... the rest of your life, and money were no object, what would you do?Holidays like Independence Day give me the excuse (and reminder) to Finding ...

How to stop your kids finding out Santa doesn’t exist: New software could help
WANT TO keep your childs’ belief in Santa alive this Christmas? Well, new research says the answer starts and ends with the internet.

Resources last updated: 12/6/2015 12:02:16 PM