473,769 Members | 6,248 Online
Bytes | Software Development & Data Engineering Community
+ 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: "masterpagelabe l";

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 19075
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.mast er.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.mas ter" 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
1957
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 beside it to turn off the help. I wrote a public method in the master page that looks like this: public void tattle(string as_msg) { microhelp.Text = as_msg; }
3
2344
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 the master. <%@ MasterType TypeName="MyMasterPage" %> How do I reference the master page class from the BasePage? Thanks...
4
11240
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
1166
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 tell me how to do this.
1
8487
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 I fix this and display the date into textbox after selecting the date from Calendar.aspx? This Very Urgent .......................... If any body help me out I have given the following Code ******************************
1
2770
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 out. here is the code <html> <HEAD> <SCRIPT LANGUAGE="JavaScript"> var captured = ""; function captext() {
1
3635
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 ...but with a twist. ) Here's the scenario: Method in MyMaster.master.cs: public void Logout(object sender, EventArgs e)
1
1426
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 Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="EditNewRequirement.aspx.vb"
1
1871
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.... protected void Page_Load(object sender, EventArgs e) { HtmlMeta fordesc = new HtmlMeta(); fordesc.Name = "keywords";
0
9423
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,...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
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,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6674
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
5304
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...
1
3963
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
3
2815
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.