Wednesday, March 28, 2012

Accessing Master page control from child page

Hi,

In my application I have implemented a customized error control, which gets visible on any error raised.

Issue is, in one of the page where we have implemnted Update Panel, and onClick of a button I wants to raise a error on the control in Master page.

The Page object has a Master property that will reference the properties of the master page. Note that you will need to apply the MasterType directive to your page or use the Page.MasterPageFile property to reference the master page properties.

hi,

You can retrieve the master page controls by using this.masterPage property.

Hope this helps


Hi,

In all my other pages I am able to access the properties of master page, but not able to access the property for the page where Update panel is implemented.


hello.

in my opinion, this is what you should do:

1. create an interface which has the properties/methods you want to access.

2. change the master so that it implements the interface. if you want to get a property from q control, don't forget to call ensurechildcontrols() beforeaccessing the control on the property code

3. on your page, start by getting a reference to the master and see if it implements the required interface. if it does, then just cast the master reference to the interface and use it to access the properties/methods you need.

No comments:

Post a Comment