473,834 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2082

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.Fi ndControl("lblM yLabel"), label)
objLabel.Text = "Whatever you want"

Regards,
Steve

Oct 27 '06 #2
"Jester98x" <st**********@w dr.co.ukwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
>In VB

Dim objLabel as Label = CType(Master.Fi ndControl("lblM yLabel"), label)
objLabel.Tex t = "Whatever you want"
And in C#:

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

-Bill

"Mark Rae" <ma**@markNOSPA Mrae.comwrote in message
news:e2******** ********@TK2MSF TNGP03.phx.gbl. ..
"Jester98x" <st**********@w dr.co.ukwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
>>In VB

Dim objLabel as Label = CType(Master.Fi ndControl("lblM yLabel"), label)
objLabel.Te xt = "Whatever you want"

And in C#:

((Label)Master. FindControl("lb lMyLabel")).Tex t = "Whatever you want";

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

Thanks a lot everybody

Mike

Mark Rae a écrit :
"Jester98x" <st**********@w dr.co.ukwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
>In VB

Dim objLabel as Label = CType(Master.Fi ndControl("lblM yLabel"), label)
objLabel.Tex t = "Whatever you want"

And in C#:

((Label)Master. FindControl("lb lMyLabel")).Tex t = "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
1107
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: http://msdn.microsoft.com/library/en-us/dnvs05/html/masterpages.asp?frame=false#masterpages_topic11 (Exposing Properties and Methods from a Master Page) here my code:
2
2839
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 a lack of reference to it. How do I supply a reference to the class so that it can populate the label? My code is below... *The reason I am doing it this way, is that I want the typical code used to supply a string to the MasterPage label to be...
5
7287
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 access the property and control of master page from the customized base page class? Btw, I can access the server control of master page from base page class via
3
2094
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, for example, that the Page_Load on the specific page executes before the Page_Load of its MasterPage. Is this right? But what I really want to understand is VARIABLE SCOPE, etc. between the two. For example: Is there a way for me to write code...
4
1622
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 = new MasterPage(); But there is no way to do something like: MasterPage master = new MasterPage("~/default.master");
6
9173
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" %> On the Master Page I have a public property exposed: Public Property ErrorMessage() As String Get Return txtError.InnerText End Get
3
2348
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: MyBody.Attribute.Add("onload","GetAccounts()");
4
1833
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 a button called B1 I then have a page called default and in the page load I tryed: System.Web.UI.WebControls.Button B10 = (System.Web.UI.WebControls.Button)Master.FindControl("B1"); System.Web.UI.WebControls.Button B20 =...
16
11621
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 ScriptManager to create PageMethods. Here's what I did: 1. I added the "ScriptManager" and the "JavaScript that calls the page method" in MasterPage...with Javascript inside the <body> tag and ScriptManager inside the <form> tag.
0
9800
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9651
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10556
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7762
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5629
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5800
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3987
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.