Reference a user controls properties from another user control??

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 =
 
J

Jeffrey Palermo

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top