Solved

master file label

Posted on 2011-03-23
3
400 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
Comment Utility
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
Comment Utility
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
Comment Utility
In VB.NET:

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
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: …

743 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

18 Experts available now in Live!

Get 1:1 Help Now