Solved

master file label

Posted on 2011-03-23
3
401 Views
Last Modified: 2012-05-11
In asp.net master page app can I display a label from the master page that reflects the page I am on?
For example I want a variable in the master page to display some instructions in the master page area depending on what webpage I am on.

0
Comment
Question by:jagguy
  • 2
3 Comments
 
LVL 13

Expert Comment

by:devlab2012
ID: 35204215
Suppose you have a label "lblMessage" on the master page, then on your content page you can change the text of this label with following statement:

Label lbl1 = (Label)Page.Master.FindControl("lblMessage");
lbl1.Text = "Text based upon content page";
0
 
LVL 51

Accepted Solution

by:
HainKurt earned 500 total points
ID: 35204221
in master add a public property

public pageName as string=""

then on any page using master page

me.master.pagename = "User Control Page"
' you may need to cast your master to masterpage type to use pagename property

and on master page_render event use this to set a label on master...
or create a property and when set, change the label.text to this value

Public Property PageName() As Integer
Get
  Return lblPageName.Text
End Get
Set(ByVal Value As Integer)
  lblPageName.Text = value
End Set
End Property
0
 
LVL 13

Expert Comment

by:devlab2012
ID: 35204227
In VB.NET:

Page.Master.FindControl("lblMessage").Text = "Text based upon content page"
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Programmatically signing Word macros 4 61
Class object 2 26
Anyway to make "All" the default in the dropdown? 6 34
Variable Event ? 3 19
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now