K
Karl Lang
Hi, I'm trying to set a property of a user control that is part of another
user control. So I have a control A which contains control B, and I'm trying
to set a property in B from within the codebehind file for A.
In control codebehind for A in page_load :
Protected objButtons As ProductButtons
objButtons = DirectCast(FindControl("ProductButtons1"), ProductButtons)
objButtons.ProductID = 8
In the ascx file for Control A
<PRODUCTBUTTONSCTRLRODUCTBUTTONS id="ProductButtons1" runat="server"
instance="1"/>
Control B has a property called ProductID
When I run the page I get "Object reference not set to an instance of an
object" on the line objButtons.ProductID = 8
Any ideas on how to get around this? can I reference the sub control B from
within the aspx page that holds control A?
klang
user control. So I have a control A which contains control B, and I'm trying
to set a property in B from within the codebehind file for A.
In control codebehind for A in page_load :
Protected objButtons As ProductButtons
objButtons = DirectCast(FindControl("ProductButtons1"), ProductButtons)
objButtons.ProductID = 8
In the ascx file for Control A
<PRODUCTBUTTONSCTRLRODUCTBUTTONS id="ProductButtons1" runat="server"
instance="1"/>
Control B has a property called ProductID
When I run the page I get "Object reference not set to an instance of an
object" on the line objButtons.ProductID = 8
Any ideas on how to get around this? can I reference the sub control B from
within the aspx page that holds control A?
klang