all groups > asp.net > february 2004 >
You're in the

asp.net

group:

User Control and Parent



User Control and Parent Joe Fallon
2/20/2004 10:05:57 PM
asp.net: What is the code to read a field value of the Parent Page from an embedded
User Control?
I can use reflection to get it, but I thought there would be an easier way.
--
Joe Fallon




Re: User Control and Parent Chris Jackson
2/23/2004 10:59:21 AM
A UserControl has a Parent property, which you can use to get a reference to
the parent. If you then cast this as the type of your parent class, you can
access any public members of that class.

....
ParentPage myParent = this.Parent as ParentPage;
if (myParent != null) {
myParent.SomeMethod();
}
....


--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

[quoted text, click to view]

Re: User Control and Parent Joe Fallon
2/23/2004 1:12:51 PM
Thanks Chris, I will give it a shot.
--
Joe Fallon



[quoted text, click to view]

AddThis Social Bookmark Button