473,387 Members | 1,464 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,387 software developers and data experts.

Access MasterPage component

Hello,

I have a master page with a label. In the "children page" in the
Page_Load function for example, I would like to change the text of the
label in the master page.

Is that possible? How can I do taht?

Thanks a lot.

Mike
Oct 27 '06 #1
5 2066

Mikaël PLOUHINEC wrote:
Hello,

I have a master page with a label. In the "children page" in the
Page_Load function for example, I would like to change the text of the
label in the master page.

Is that possible? How can I do taht?

Thanks a lot.

Mike
Mike,

In VB

Dim objLabel as Label = CType(Master.FindControl("lblMyLabel"), label)
objLabel.Text = "Whatever you want"

Regards,
Steve

Oct 27 '06 #2
"Jester98x" <st**********@wdr.co.ukwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>In VB

Dim objLabel as Label = CType(Master.FindControl("lblMyLabel"), label)
objLabel.Text = "Whatever you want"
And in C#:

((Label)Master.FindControl("lblMyLabel")).Text = "Whatever you want";
Oct 27 '06 #3
And I think you need to add the
<%@ MasterType VirtualPath="~/MasterPage.master"%>
directive to the aspx page, right?

-Bill

"Mark Rae" <ma**@markNOSPAMrae.comwrote in message
news:e2****************@TK2MSFTNGP03.phx.gbl...
"Jester98x" <st**********@wdr.co.ukwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>>In VB

Dim objLabel as Label = CType(Master.FindControl("lblMyLabel"), label)
objLabel.Text = "Whatever you want"

And in C#:

((Label)Master.FindControl("lblMyLabel")).Text = "Whatever you want";

Oct 27 '06 #4
"BillE" <be****@datamti.comwrote in message
news:ud****************@TK2MSFTNGP05.phx.gbl...
And I think you need to add the
<%@ MasterType VirtualPath="~/MasterPage.master"%>
directive to the aspx page, right?
Wrong.
Oct 27 '06 #5
It works.

Thanks a lot everybody

Mike

Mark Rae a écrit :
"Jester98x" <st**********@wdr.co.ukwrote in message
news:11**********************@k70g2000cwa.googlegr oups.com...
>In VB

Dim objLabel as Label = CType(Master.FindControl("lblMyLabel"), label)
objLabel.Text = "Whatever you want"

And in C#:

((Label)Master.FindControl("lblMyLabel")).Text = "Whatever you want";

Oct 30 '06 #6

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

Similar topics

0
by: Tony | last post by:
Hi, I'm trying to access properties from a masterpage. With no success. Can somebody help me please? I used the example at:...
2
by: dawg1998 | last post by:
I am trying to access a label located in a MasterPage from a class located in my application's App_Code folder. The problem seems to be that the class cannot communicate with the MasterPage due to...
5
by: RedHair | last post by:
I have a ASP.NET 2.0 web page which inherits a customized base page class and have a master page, their relation is as below Customized base page class --> web page --> master page How to...
3
by: Alex Maghen | last post by:
Hi. I'm a little confused about the code that resides in the code-behind of a MasterPage and the code that resides in the code-behind of the actual pages that USE that MasterPage. I'm noticing,...
4
by: cevans | last post by:
Is there a way to load a MasterPage programmatically? Not switch a page's masterpage but to create a MasterPage object that holds a given masterpage. So I know I can do: MasterPage master =...
6
by: =?Utf-8?B?SmF5IFBvbmR5?= | last post by:
I am trying to access a Public property on a Master Page from a Base Page. On the content pages I have the MasterType Directive set up as follows: <%@ MasterType virtualpath="~/Master.master" %>...
3
by: tshad | last post by:
In VS 2005, I need to get access to the body tag which I have set up on my Master Page as: <body ID="MyBody" runat="server"> But when do something like: ...
4
by: Torben Laursen | last post by:
I want to change the label of a component that I have on a masterpage but I cannot get my hands on it I have a mastepage MP2 that has a button called B2 masterpage MP2 uses masterpage MP1 that has...
16
krungkrung
by: krungkrung | last post by:
Hi all, Can somebody help me figure out whats wrong with my program? I created a site with the use of MasterPage..and with a plan of utilizing and abusing the capabilities of AJAX, I added the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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?
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.