Is it possible to set a control on the masterpage from a content page.
Or can you only place stuff in the contentplace holder.
f.e i want to place a label on the masterpage.
and put info in it from a contentpage created from the masterpage
thanxI don't think so and probably this violates the benefit of master pages.
Hi,
Pirate: This can be useful if you have a label on your page and want to change it to reflect what is in your content and I don't see a problem with this myself but my ears are always open to suggestions...
spoofer: You can do it like this...
In your master page define a property public string setLabel
{
set { this.lblTitle.Text = value; }
get { return this.lblTitle.Text; }
}
Then in your content page at the top of the .aspx<%@. MasterType VirtualPath="~/base.master" %>
and in your content page codebehindthis.Master.setLabel = "This is new label";
I'm just following what's called 'best practice' from MS... :p.I've not seen anyone doing it this way.It could be right but rarely used!
Thanx Fishcake, just what i was looking for!
Example + Demo
here:
http://www.geula.biz/works/sample/asp%20net/addControlFromTheContentToTheMaster.aspx
I'm just following what's called 'best practice' from MS... :p.I've not seen anyone doing it this way.It could be right but rarely used!
Not necessarily 'best', then.
There are certain dependencies that do arise in some applications, because a Master Page cannot necessarily be so static. It's also why Master Pages are actually controls that are injected into a page that 'uses' the master page.
Thursday, March 29, 2012
set control on masterpage
Labels:
asp,
content,
contentplace,
control,
holder,
masterpage,
net,
page,
stuff
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment