CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums

ASP.NET Web Hosting – 3 Months Free!



Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 5/19/2007 2:37:05 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 2 Views: 457 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
3 Items, 1 Pages 1 |< << Go >> >|
kioria
Asp.Net User
Nested Master Pages and Page controls5/19/2007 2:37:05 PM

0/0

Hi,

I am having difficulties trying to find a control which exists on a page which uses a mater page (nested) but is declared on one of the master pages. To make it easier to understand here's how my code is set up.

I have two master pages:

  1. MasterBase
  2. MasterPage

The MasterPage has a Content control which plugs straight into MasterBase's ContentPlaceHolder. The MasterPage's Content control contains ContentPlaceHolder so that ASPX pages that inherit this MasterPage can plug their Content(s) into those ContentPlaceHolders.

Home.aspx, which I have created uses the MasterPage - and in Content control of the Home.aspx file I have a couple of controls like Label (let's say ID="lblContent1") or Buttons and etc.

What I need to be able to do is, from MasterBase, detect if the page (being rendered) contains certain controls. So for example, in MasterBase's codebehind, I want to look for a control called "lblContent1" and if it does exist, I want to populate it with some data.

Right now, I haven't been successful at doing this. How can I achieve this?

 

Thanks Yes

aaroncollett
Asp.Net User
Re: Nested Master Pages and Page controls5/19/2007 11:39:35 PM

0/0

Something along the lines of:

Label l = null;

l = this.ContentPlaceHolder1.FindControl("Label1") as Label;

if (l != null) {

l.Text = DateTime.Now.ToShortDateString();

}

should do it. 'this' being the root master page. If you have more complex nesting, then you may have to get a reference to the content placeholder which contains the nested master first (and extract a reference to the master), but once you have the reference to the correct master, the same approach should work.

HTH

Aaron

Amanda Wang - M
Asp.Net User
Re: Nested Master Pages and Page controls5/23/2007 4:44:31 AM

0/0

Hi,

The label of the content  page is a protected menber, so you shoud define a public member in the content page and expose the Hidden Field.

 

if  Still use the FindControl function. For the label in the Content page, its structure can be like the following:

  

FindControl("ctl00$ContentPlaceHolder1$HiddenField1")

hope it helps.


Please remember to mark the replies as answers if they help and unmark them if they provide no help.


Yours sincerely,
Amanda Wang
Microsoft Online Community Support
3 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Professional C# 2008 Authors: Christian Nagel, Bill Evjen, Jay Glynn, Karli Watson, Morgan Skinner, Pages: 1782, Published: 2008
ASP.NET 2.0: Your Visual Blueprint for Developing Web Applications Authors: Chris Love, Pages: 339, Published: 2007
Professional ASP.NET 3.5 in C and VB: In C# and VB Authors: Bill Evjen, Scott Hanselman, Devin Rader, Pages: 1704, Published: 2008
Beginning ASP.NET 3.5: In C# and VB Authors: Imar Spaanjaars, Pages: 734, Published: 2008
ASP.NET 2.0 Website Programming: Problem-design-solution Authors: Marco Bellinaso, Pages: 576, Published: 2006
Foundations of Microsoft Expression Web: The Basics and Beyond Authors: Cheryl D. Wise, Pages: 370, Published: 2007
Pro ASP.NET 2.0 Website Programming Authors: Damon Armstrong, Pages: 641, Published: 2005
Microsoft Visual C# 2005 Unleashed Authors: Kevin Hoffman, Pages: 692, Published: 2006
Beginning ASP.NET 2.0 in VB 2005: From Novice to Professional Authors: Matthew MacDonald, Pages: 1063, Published: 2006
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007

Web:
CodeProject: Accessing Controls on Nested Master Page from Content ... Oct 30, 2007 ... Accessing Controls on Nested Master Page from Content Pages using Dynamic Polymorphism without casting to MasterPage classes; Author: Gyan ...
Nested Master Pages and Page controls - ng.asp-net-forum ... Nested Master Pages and Page controls, > ROOT > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls, ...
VS 2008 Nested Master Page Support - ScottGu's Blog Master file called "MainContent" - and automatically added a blank control within this nested master page so that we can override and ...
Nested master page (C#) : Master page « User Control and Master ... Nested master page (C#) : Master page « User Control and Master Page « ASP.Net.
Walkthrough: Using Nested Master Pages in ASP.NET This walkthrough describes how to create a master page that is nested inside ... NET pages. The body of the page contains a ContentPlaceHolder control, ...
CodeSnip: Find Control in Nested Master Pages: ASP Alliance Oct 8, 2008 ... In this article, Abdulla examines how to find a control from Content Page inside two Nested Master Pages using Visual Studio 2008. ...
Nested Master Pages This will be done by first covering what is a Nested Master Page, ..... page with contentplaceholder controls that match the names in your nested master. ...
Is it better to use Nested Master pages or User Controls for multi ... Use the new nested master page capabilities to create 5 sub-master pages. Use a single master page and dynamically load user controls corresponding to each ...
Serve's Sharepoint Blog: Why use nested master pages? Jan 12, 2009 ... Option #1: You could for instance, change the master page. Locate the asp.net menu control for the top navigation and change the number of ...
Nested Master Page Visual Web 2008 3.5 Feb 22, 2008 ... By using nested master pages, you can control the layout structure in ... The new support for master page nesting is purely a Visual Studio ...




Search This Site:










controls and passing values using reflection

connection string in web.config

to help protect your computer...active content blocked

select,edit,delete,update data in datagridview control[c#]

variable query

remote access error

using custom stand-alone classes without compiling dlls

textbox focus

counting a specified char in a string?

vs.net & tabletpc

barcdode validation

scanner integration in web page

returning an error message

searching a access db

.net runtime errors in event viewer

delete

passing variables with linkbutton

how can i do this?

problem connecting to the server

login request for every pop-up window of my web-application

date problem

re:requet on aspx page

custom controls in asp.net web site

sending values to the client function

underline color

literal control text manipulation

propertous menu :) i have hide my propertous menu and i cant find it :) where is it ?

response.redirect () function auto redirect to cannot display this page ????

globalasax problem, user.identity causing an error

launch a windows exe from within ie

  Privacy | Contact Us
All Times Are GMT