J
John A Grandy
Let's say I have an .aspx Page instance derived from class "MyPage" (which
of course inherits from System.Web.UI.Page).
On the .aspx Page , I have "uc1", an instance of a UserControl dervived from
"MyUserControl".
uc1 is contained in a <td> in a <tr> in a <table> in a <td> in a <tr> of
another <table> ... or some other form of deep nesting.
In uc1 's code-behind I'd like to reference some properties of the parent
Page.
I tried this code:
Dim parentPage As MyPage
parentPage = CType(Parent,MyPage)
but this throws a "cast invalid" error.
The only solution that occurs to me seems a little absured ....
Is ASP.NET written so that you must climb up the page's HTML control
hierarchy in some manner ?
In other words, should I be using something like :
parentPage =
CType(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent,MyPage)
of course inherits from System.Web.UI.Page).
On the .aspx Page , I have "uc1", an instance of a UserControl dervived from
"MyUserControl".
uc1 is contained in a <td> in a <tr> in a <table> in a <td> in a <tr> of
another <table> ... or some other form of deep nesting.
In uc1 's code-behind I'd like to reference some properties of the parent
Page.
I tried this code:
Dim parentPage As MyPage
parentPage = CType(Parent,MyPage)
but this throws a "cast invalid" error.
The only solution that occurs to me seems a little absured ....
Is ASP.NET written so that you must climb up the page's HTML control
hierarchy in some manner ?
In other words, should I be using something like :
parentPage =
CType(Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent,MyPage)