By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,972 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,972 IT Pros & Developers. It's quick & easy.

Reference a user controls properties from another user control??

P: n/a
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 =
Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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("idForUserContr ol")).Property = value;

just switch the syntax to VB. Page.FindControl(". . .") is what you are
looking for.
-Jeffrey Palermo
"abjork" <an*******@discussions.microsoft.com> wrote in message
news:82**********************************@microsof t.com...
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.FormStandard
....
formStandard.Market = 4

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.