Reference a user controls properties from another user control??

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a aspx page with two user controls. One of them holds some properties that I would like to set from the other user control. How do I do that

I keep getting "Object reference not set to an instance of an object." when I declare the first user control like this from within the second UC

Public formStandard As PIC.FormStandar
....
formStandard.Market =
 
First of all, a UserControl should be an atomic object. By referencing
properties of another user control (that you THINK will be on the page) from
a user control, you are eliminating the possibility of using this user
control on another page by itself, and the benefit of encapsulating content
and code is gone. However, this is how you do it.

From within the user control:
((UserControlType)Page.FindControl("idForUserControl")).Property = value;

just switch the syntax to VB. Page.FindControl(". . .") is what you are
looking for.
-Jeffrey Palermo


abjork said:
I have a aspx page with two user controls. One of them holds some
properties that I would like to set from the other user control. How do I do
that?
I keep getting "Object reference not set to an instance of an object."
when I declare the first user control like this from within the second UC:
 
Back
Top