Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

master file label

Posted on 2011-03-23
3
Medium Priority
?
409 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 61

Accepted Solution

by:
HainKurt earned 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses

772 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