I have a UserControl which uses a UserControl, among other controls.
In the ascx
file I have the following code:
<%@ Register TagPrefix="tag" Namespace="some.name.space" Assembly="some.assembly" %>
<tag:control ID="test" runat="server" />
In my Page_Load
method, I try to set a property on test like so:
test.Text = "Hello World!";
This actually sets the Text property of a literal control in my user control test
.
This throws an exception:
Object reference not set to an instance of an object
When it tries to set the
lblTest.Text = value;
The object that is null is lblTest
.
Am I not adding the user control correctly? Should I - or do I have to - specify the Src
property when registering a Tag? If so, I'd have to register every usercontrol I use?
This also results in no controls loading in usercontrol and all controls are null within usercontrol.