Setting Properties of User Control On Master Page

M

Mick Walker

Hi All,

I have a user control on my master page, which exposes 3 public
properties (all boolean). Basically by the values of these properties,
the user control builds a menu to for users to navigate through the website.

I am wondering, how can I set the property of a usercontrol contained
within a Master Page, from a content page?

Kind Regards
 
G

Guest

Usually by exposing them as Master page properties - as your user control is
"internal" to the master page, it makes sense to only manipulate them within
it.
 
B

Brandon Gano

--master.master--
<asp:Label ID="lblWelcomeMessage" runat="server" />

--master.master.cs--
public string WelcomeMessage
{
get { return lblWelcomeMessage.Text; }
set { lblWelcomeMessage.Text = value; }
}

--page.aspx.cs--
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
this.Master.WelcomeMessage = "Hello World!";
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top