473,385 Members | 2,180 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

access content page controls from within the master page

Hello!
I need to access content page controls from within the master page.
How can I do that??

Nov 23 '05 #1
4 1395
I answered your earlier post...
--

<ph***********@web.de> a écrit dans le message de
news:11**********************@g14g2000cwa.googlegr oups.com...
Hello!
I need to access content page controls from within the master page.
How can I do that??

Nov 23 '05 #2
Thanks, but I need to access to the content page from the master page.
Now I have programed it like this:
The Label1 is in the Content Page, this Source is in the MasterPage.
in the Page Load:
if (Page.title=="MyContentPage")
{
GetControls(this, "Label1");
Label myLabel = (Label)Convert.ChangeType(myC,
typeof(Label));
myLabel.Text = "other Text";
}
the procedure GetControls:
public void GetControls(Control c, string FindControl)
{
foreach (Control cc in c.Controls)
{

if (cc.ID == FindControl)
{
myC = cc;
break;

}

if (cc.Controls.Count>0)
GetControls(cc,FindControl);

}

}

myC is a private property:
private Control myC;

Nov 23 '05 #3
Missed the point. This is done as with any other control that is just
ContentPlaceHolder1.FindControl("Label1").

--
Patrice

<ph***********@web.de> a écrit dans le message de
news:11**********************@f14g2000cwb.googlegr oups.com...
Thanks, but I need to access to the content page from the master page.
Now I have programed it like this:
The Label1 is in the Content Page, this Source is in the MasterPage.
in the Page Load:
if (Page.title=="MyContentPage")
{
GetControls(this, "Label1");
Label myLabel = (Label)Convert.ChangeType(myC,
typeof(Label));
myLabel.Text = "other Text";
}
the procedure GetControls:
public void GetControls(Control c, string FindControl)
{
foreach (Control cc in c.Controls)
{

if (cc.ID == FindControl)
{
myC = cc;
break;

}

if (cc.Controls.Count>0)
GetControls(cc,FindControl);

}

}

myC is a private property:
private Control myC;

Nov 23 '05 #4
It's simpler as I thought.

Thanks

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: phil1bruening | last post by:
Hello! I need to access master page controls from within content pages. Wow can I do that??
3
by: ilockett | last post by:
The background: I have a web app with a simple master page that contains just one content placeholder. I have created a web form that then uses this master page. Within the content...
4
by: RedHair | last post by:
I have a base page class A which inherits System.Web.UI.Page class then a aspx page B inherits class A and have a master page C. There is a property D (a string variable) in the master page C. ...
5
by: Paul | last post by:
I have a MasterPage that has on it several UserControls (*ascx files). I wish to control the visibility of the controls on the content pages according to some parameter (for example on a user...
3
by: ivanpais | last post by:
Hi, I have a Web User Control, Lets say "Foo.ascx", that contains a button "btnFoo". I have a Master Page "Bar.master", that has a label "lblBar". This label is exposed by a public property...
4
by: Boris Yeltsin | last post by:
OK, on my Master Page I have a control: <a id="hypTabAccount" href="#" runat="server">Account</a> Now, in the code-behind (Root.master.vb) I can refer to it simply thus: ...
4
by: ~john | last post by:
If I have a label on the Master Page that I would like to change its text with a button on one of the content pages, Default.aspx... It's giving me an error saying "Label1" is not found. Can you...
3
by: MikeB | last post by:
Hello, I have a content page that is from a Master page which has 2 content panes. How do I add my forms to the content page? Each pane needs a form but you can not have multiple form tags nor...
3
by: eselk2003 | last post by:
I'm just starting out with VWD 2008, and new to ASP .NET. I have a master page which displays one record for an Access database based on an ID number in the query string. Then I have a content...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.