Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Sign In| Join
All-Star
46224 Points
6896 Posts
ASPInsiders
MVP
Jan 15, 2006 11:48 AM|LINK
Hi,
your Master page be it MasterPage.master could expose a property which wraps to the Label's (Label1) Text property.
Public Property LabelText() As String Get Return Label1.Text End Get Set(ByVal value As String) Label1.Text = value End Set End Property
Content page would then need to have @MasterType directive so that the property could be accessed via Master in a typed manner.
<%
Then, code on content page could just do:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not Page.IsPostBack Then Master.LabelText = "This text goes to the Label on master page" End If End Sub
joteke
All-Star
46224 Points
6896 Posts
ASPInsiders
MVP
Re: How to asign text to a label in master page from content page?
Jan 15, 2006 11:48 AM|LINK
Hi,
your Master page be it MasterPage.master could expose a property which wraps to the Label's (Label1) Text property.
Public Property LabelText() As String
Get
Return Label1.Text
End Get
Set(ByVal value As String)
Label1.Text = value
End Set
End Property
Content page would then need to have @MasterType directive so that the property could be accessed via Master in a typed manner.
<%
@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" title="Untitled Page" %><%
@ MasterType VirtualPath="~/MasterPage.master" %>Then, code on content page could just do:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
Master.LabelText = "This text goes to the Label on master page"
End If
End Sub
Teemu Keiski
Finland, EU