|
|
|
start date: Wed, 15 Aug 2007 09:52:03 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Arne
|
|
2
Ladislav Mrnka
|
|
3
田德振(Nocky Tian)
|
|
4
Alexey Smirnov
|
Master pages
How do I pass user defined data between a content page and a master page?
My content page needs to change the menu options in my masterpage.
--
Arne Garvander
Certified Geek
Professional Data Dude
Date:Wed, 15 Aug 2007 09:52:03 -0700
Author:
|
RE: Master pages
Hi Arne,
your content page contains property named Master which allows you to get
reference to your master page. This property returns instance of MasterPage
class by default so you have to cast it to your master page class.
If you want to have strongly typed system you have to insert MasterType
directive to your content page. After that Master property will return
instance of type defined in this directive.
So now you have an idea how to access Master page but this is still not end
of the story ;) You have to define public properties and methods on your
master page to allow modifications to UI outside of this class (all UI
elements are marked as protected by default).
Regards,
Ladislav
"Arne" wrote:
> How do I pass user defined data between a content page and a master page?
> My content page needs to change the menu options in my masterpage.
>
> --
> Arne Garvander
> Certified Geek
> Professional Data Dude
Date:Wed, 15 Aug 2007 10:34:04 -0700
Author:
|
Re: Master pages
On Aug 15, 7:34 pm, Ladislav Mrnka
wrote:
> Hi Arne,
> your content page contains property named Master which allows you to get
> reference to your master page. This property returns instance of MasterPage
> class by default so you have to cast it to your master page class.
>
> If you want to have strongly typed system you have to insert MasterType
> directive to your content page. After that Master property will return
> instance of type defined in this directive.
>
> So now you have an idea how to access Master page but this is still not end
> of the story ;) You have to define public properties and methods on your
> master page to allow modifications to UI outside of this class (all UI
> elements are marked as protected by default).
>
> Regards,
> Ladislav
>
>
>
> "Arne" wrote:
> > How do I pass user defined data between a content page and a master page?
> > My content page needs to change the menu options in my masterpage.
>
> > --
> > Arne Garvander
> > Certified Geek
> > Professional Data Dude- Hide quoted text -
>
> - Show quoted text -
Example:
-- Master --
public partial class Site1 : System.Web.UI.MasterPage
{
private int menu_id;
protected void Page_Load(object sender, EventArgs e)
{
if (menu_id == 0) {
.....
}
}
// this is an example of public property to set menu_id
public int MenuID
{
set { this.menu_id = value; }
}
}
Now in the content page you can set menu_id
Site1 m = (Site1)(Page.Master);
m.MenuID = 0; // homepage
That's all
Date:Wed, 15 Aug 2007 18:05:49 -0000
Author:
|
Re: Master pages
try
Page.Master.FindControl('controlID')
Date:Sat, 18 Aug 2007 00:16:32 +0800
Author:
|
|
|