I have an aspx page that inherits a master page which has a protected property. Like this:
masterpage { protected string propX.. }
MyPage : masterpage
---myControl:UserControl
In myControl code-behind I'd like to access propX
Any ideas?
Thanks!
I have an aspx page that inherits a master page which has a protected property. Like this:
masterpage { protected string propX.. }
MyPage : masterpage
---myControl:UserControl
In myControl code-behind I'd like to access propX
Any ideas?
Thanks!
On
Are you sure you're inheriting from the master page? Adding the MasterPage directive doesn't mean that it inherits from it. Usually an aspx page should directly or indirectly inherit from System.Web.UI.Page.
The master pages aren't "inherited" which means that protected members cannot be accessed from the page class (or control class). Your best option is to make the property public or internal.
Maybe try to cast the
Pageproperty ofmyControlclass toMyPageclass?And if you want to access this property from other class (like
myControl), the access modifier of propertypropXshould be set tointernalorpublicI've assumed, that you've placed
myControlobject onMyPagepage.