Problem Accessing Page Controls in a page that has a master page.

Hi, 

I have a problem with accessing the controls of a page that has a masterpage. I am trying to access the Page.Controls from the code behind in the class file but no controls are returned.

I can access single controls (ex. txtAddress.Text) but not the whole array of controls (ex. Page.Controls). 

The controls structure is..

                                 MasterPage  >  PlaceHolder > MyPage.aspx

 Any Help?? Hmm

 10x

0
BlackCell
10/24/2007 7:35:44 AM
asp.net.web-forms 93655 articles. 6 followers. Follow

3 Replies
1726 Views

Similar Articles

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

 Do you mean that you want to access controls on the master page from code on the content page? If so, read this.


Website Design Darlington - http://mdssolutions.co.uk
http://lessthandot.com - Experts, Information, Ideas & Knowledge
http://aspnetlibrary.com - An online resource for professional ASP.NET developers


Please remember to click "Mark as Answer" on this post if it helped you

0
ca8msm
10/24/2007 8:46:57 AM

Hey thanks for the reply,

 

No actually not the master page controls but the same page controls as a collection.

Because I have a table and in that table cells I have some  controls I want to access as a whole collection...I have managed to do it but using loops, and I think there is a more efficient way using control collections. 

 To give you a more clear example here is the hierarchy of the page: 

Masterpage
       '-->  PlaceHolder
                 '-->  Web Content Form
                              '-->  Table
                                        '--> Asp Table
                                                     '--> (The Contols I want to access are here)


Hope it shows a clear view of how the page structure is, maybe someone can help me.


10x again.

0
BlackCell
10/24/2007 9:07:46 AM

In that case you will need to write a recursive function (which is a function that calls itself) as the controls you want to get to are actually part of another control 


Website Design Darlington - http://mdssolutions.co.uk
http://lessthandot.com - Experts, Information, Ideas & Knowledge
http://aspnetlibrary.com - An online resource for professional ASP.NET developers


Please remember to click "Mark as Answer" on this post if it helped you

0
ca8msm
10/24/2007 9:11:56 AM
Reply:

Similar Artilces:

Paging Paging Paging
I am trying to do paging with my search results and it isnt working very well. Here is what I've tried and I feel I've tried everything, lol, please help me out. Sub DataGrid1_SortCommand(Sender as object, e as DataGridSortCOmmandEventArgs) DataGrid1.DataBind() End Sub Sub Datagrid1_PageIndexChanged(Sender as object, e as DataGridPageChangedEventArgs) Dim ds as dataSet DataGrid1.CurrentPageIndex = e.NewPageIndex if Session("Search") is nothing then 'Session probably has expired, get the datasource from database Datagrid1.DataSource = ...

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

Accessing Master Page Controls from Page
How can a page access its master page controls? Suppose a page's (.aspx) master file (.master) contains a control (e.g., Label myLabel).  How can one access the master file's control(s) within the scope of the page?  The this.Master.Controls collection (where this is the page in question) does not return what one would most likely think it would return. Hi    you can do this using javascript like    document.getelementbyid("<%controlname.clientid%>").value http://www.codeproject.com/KB/aspnet/InsideMasterPages.aspx http:...

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

The Master Page file is not valid. Attach a different Master Page, or correct the problem in the specified Master Page.
 Hi all,I've created a site with a couple of nested Master Pages. Site runs and compiles without error. I need to get it set up in Expressions now so that the non-technical content creators are able to edit it but when I try to attach a Master Page to a newly created file, it just hangs with 'Loading Master Page...'. If I subsequently detach the Master Page, it shows the error: The Master Page file 'http://localhost/layout/images/masterpages/SectionInnerPageChild.Master' is not valid. Attach a different Master Page, or correct the problem in the specified Master Page...

HELP..... Master Page Error (The page has controls that require a Master Page, but none is specified.)
Hi, I had almost finished creting my master page to use as a template for all future internal applications.  I had created a template to use in creatign new applications and had sucessfully created a new project based upon the MasterPage template... All was working well when I noticed a small graphic inconsistancy on the MasterPage... I reopened the MasterPage and I got teh above error message... I have looked at the HTML and everything seems to be okay and there including the header lines... <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits=&qu...

Role authorization
For role authorization if we specify location path is there any way to notify a user that they were denied access to a directory instead of just redirecting them to the forms logon page with no feedback. For instance if i put the following location path in my web.config file and a user tries to access a link to a file in the folder it just shows them the forms logon page. If they type their username and password it redirects them immediately back to the user logon page. There is no feedback that they do not have access to the folder. Is there an event i can hook into to either direct them to...

Accessing Controls Content Pages from Master Page
how do i access controls content pages from master page?Its all about coding! I would raise an event from the master page and handle it on the content page.  You can commuicate any data through customized event args.  This article explains in detail how to raise and consume an event: http://msdn2.microsoft.com/en-us/library/9aackb16(VS.80).aspx  HTH,Phillip Williams,http://www.webswapp.com Let's say your master page has a textbox whose ID is MasterTextBox. TextBox tb = Page.Master.FindControl("MasterTextBox") as TextBox;...

Content page accessing master page controls?
I'm probably that much of a noob that I've deviated from the path authors of ASP.NET 2.0 thought of how master and content pages should off been used... Looking from the outside it seemed logical to me that (even on this website) a search text box should be part of a master page and a page that displays results should be a content page... So the problem I'm having (if my hunch about that search textbox control in the header of say even this very website being part of a master page, and result page that subsequently loads underneath the header after you click go bei...

Accessing Master page control from child page
Hi, In my application I have implemented a customized error control, which gets visible on any error raised. Issue is, in one of the page where we have implemnted Update Panel, and onClick of a button I wants to raise a error on the control in Master page. The Page object has a Master property that will reference the properties of the master page.  Note that you will need to apply the MasterType directive to your page or use the Page.MasterPageFile property to reference the master page properties.Christopher Reed"The oxen are slow, but the earth is patient." hi, Y...

Accessing master page controls from content page
Hello,Here's a snippet from my listing.master page:<%@ master Language="C#" %>     public string Listing_Name    {        get { return lis_name.Text; }    }    protected void Page_Load(object sender, EventArgs e)    {       lis_name.Text = "Hello World"    } ---------------------------------------------------------------------------------------------------------------In my content page, Master.Listing_Name shows blank, why?<...

Accessing Content Page Control From Master Page
I'd like to access the value of a control residing on a content page from the associated master page. Can anyone point me in the right direction?   Thanks When you know the classname of your page, use: (in VB.NET) CType(Page, classname).ControlID.propertyName But this code will go wrong on all the other pages, so you have to check on which page you are. This being said, I advise you to consider another approach.Your master page should not use code that depends on the design of a particular content page. Your content pages should depend on your master page, not the other ...

Access Content Page Control from Master Page
I use Master page in my application. i want to access the content page control (Text Box)  from master page and change the control (Text Box) value. i cant find the text box by using Findcontrol also Let’s turn to the FindControl documentation on MSDN. FindControl searches the current naming container for the specified server control. Master.FindControl("ContentPageHolder1").FindControl(TextBox) Reading this nice article.http://odetocode.com/Articles/450.aspx   MPI never desire to converse with a man who has written more than he hasread. -Samuel Johnson, lexic...

Web resources about - Problem Accessing Page Controls in a page that has a master page. - asp.net.web-forms

Highest Percentage Of Opera Mini Users Accessing Facebook? Macau
If you were asked to guess which country had the highest percentage of users of Opera mobile Web browser Opera Mini users accessing Facebook ...

International Users Accessing Facebook Places Through US VPN Accounts
By using a virtual private network (VPN) hosted in the United States, Facebook users from around the world are accessing Facebook Places. The ...

What are some alternatives to Yodlee for accessing bank information?
Clay Loveless , Founder, Jexy. Co-founder, Mashery. Founder, Jexy. Co-founder, Mashery.

Cloud Console - Accessing files in cloud storage for iPad on the iTunes App Store
Get Cloud Console - Accessing files in cloud storage on the App Store. See screenshots and ratings, and read customer reviews.

Meryl Streep On Accessing The Characters Within - YouTube
Meryl Streep talks about the importance of an actors work representing their ability. CONNECT WITH AFI: http://facebook.com/AmericanFilmInstitute ...

Accessing the Future Fund a sensible proposal, says super expert Daryl Dixon
As portfolios go, the Future Fund's asset allocation is concentrated in higher-risk investment, including equities and alternative assets.

Accessing my Super
I'm 57 - can I access my super?

Australia, US accessing Indonesian telephone data, leaked documents show
Newly disclosed documents from former US intelligence contractor Edward Snowden have revealed that Australian intelligence efforts against Indonesia ...

Euthanasia advocate Philip Nitschke detained at Melbourne Airport, accuses Customs officials of accessing ...
Euthanasia advocate Philip Nitschke has accused Customs officials of accessing hundreds of patients' sensitive records on his laptop after detaining ...

Frances Abbott scholarship: Sydney woman pleads guilty to accessing Whitehouse Institute records on PM's ...
A Sydney woman who leaked the student records of Tony Abbott's daughter pleads guilty. A Sydney woman who leaked the student records of Prime ...

Resources last updated: 12/19/2015 1:19:18 PM