User Control and Parent

  • Thread starter Thread starter Joe Fallon
  • Start date Start date
J

Joe Fallon

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.
 
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();
}
....
 
Back
Top