473,488 Members | 2,464 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Change Master Page Label Text in from Content Page.

42 New Member
Hi, all

In my Asp.net application, I have A Master Page, which has a Label & its id is: "masterpagelabel";

now i want to change the Text of this Label When the Content Page Loads

My code is:

Expand|Select|Wrap|Line Numbers
  1. void Page_Load(...........)
  2. Label mylabel=(Label)Master.FindControl("masterpagelabel")
  3.  
  4. if(mylabel !=Null)
  5. {
  6.  mylabel="Details";
  7. }
  8. else
  9. {}
Jan 13 '09 #1
1 18999
Curtis Rutland
3,256 Recognized Expert Specialist
OK, here's what you can do. In your master page's codebehind, expose a public property that gets and sets the label.
For example:
in MasterPage.master.cs
Expand|Select|Wrap|Line Numbers
  1. public string MasterPageLabel
  2. {
  3.   get { return masterpagelabel.Text; }
  4.   set { masterpagelabel.Text = value; }
  5. }
Then, add this directive to the top of your content page, right below the @Page directive:
content.aspx
Expand|Select|Wrap|Line Numbers
  1. <%@ MasterType VirtualPath="~/MasterPage.master" %>
Now you should be able to access the property you just added:
content.aspx.cs
Expand|Select|Wrap|Line Numbers
  1. Master.MasterPageLabel = "some text";
Remember to change the path "MasterPage.master" to whatever name you were using.
Jan 13 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
1934
by: Rik Brooks | last post by:
OK, now I'm getting excited. I actually created a master page and added two content place holders to it. I also added a label which will serve as a sort of one line help and a little image button...
3
2323
by: Managed Code | last post by:
I have a BasePage class that derives from System.Web.UI.Page. All of my content pages derive from this. The derived page classes use the following MasterType declaration that follows to reference...
4
11215
by: Phil | last post by:
Hi, How to add programmatically a label into a content page? I tried this but doesn't work: Thanks Phil content page:
2
1152
by: archana | last post by:
Hi all, i have one master page having one lable control. I want to update content of that lable through content page. I tried to find it using Master properly but of no luck. can anyone...
1
8454
by: sudip2008 | last post by:
When using the Calendar Popup in a content page of a masterpage the strForName is always set to aspnetForm This breaks this line from working properly window.opener.document.forms...... How can...
1
2743
by: destiny007 | last post by:
can any one help me to write code to capture selected text from a page but problem is that i am not able to decide where to call the functio.in this case the function is called in all cases of mouse...
1
3616
by: DevNll2002 | last post by:
Can it be done? ( This is a related issue to my recent post... http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/a229a66642bedfaf/870614ae257ae699...
1
1412
by: Ex glider pilot | last post by:
Hi I have a public property on a master page: Public Sub SetTitle(ByVal TitleText As String) Me.lblMessage.Text = TitleText End Sub the page def of the content page is: <%@ Page...
1
1857
by: Sinan Alkan | last post by:
In a master page --content page system, is it possible to change the "description" and "keywords" meta tags of the master page from content page ? I am trying as follows, from content page.... ...
0
7142
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,...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
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...
0
4565
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...
0
3078
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...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.