<p>I have an Asp.NET application (VS2008, Framework 2.0). When I try to set a property on one of the user controls like</p>

<pre><code>myUserControl.SomeProperty = someValue;
</code></pre>

<p>I get a <code>NullReferenceException</code>. When I debug, I found out that <code>myUserControl</code> is null. How is it possible that a user control handle is null? How do I fix this or how do I find what causes this?</p>

[{'answer_id': 30301, 'author': 'Jay Mooney', 'author_id': 733, 'author_profile': 'https://Stackoverflow.com/users/733', 'pm_score': 4, 'selected': True, 'text': '<p>Where are you trying to access the property?  If you are in onInit, the control may not be loaded yet.</p>\n'}, {'answer_id': 30305, 'author': 'ChrisAnnODell', 'author_id': 1758, 'author_profile': 'https://Stackoverflow.com/users/1758', 'pm_score': 3, 'selected': False, 'text': '<p>Where exactly in the code are you attempting to do this?  It is possible that you are attempting to access the control too early in the <a href="http://msdn.microsoft.com/en-us/library/ms178472.aspx" rel="noreferrer">page lifecycle</a> and it has not been instantiated yet.</p>\n'}, {'answer_id': 30308, 'author': 'labilbe', 'author_id': 1195872, 'author_profile': 'https://Stackoverflow.com/users/1195872', 'pm_score': 0, 'selected': False, 'text': '<p>If you created the UserControl during runtime (through ControlCollection.Add), you need to create it on postback too.</p>\n\n<p>Another case can be your UserControl does not match the designer.cs page</p>\n'}, {'answer_id': 30339, 'author': 'Serhat Ozgel', 'author_id': 31505, 'author_profile': 'https://Stackoverflow.com/users/31505', 'pm_score': 0, 'selected': False, 'text': '<p>I was trying to set the property from markup on an outside user control. When I took the property to OnLoad, it worked.</p>\n'}]
['https://Stackoverflow.com/questions/30286', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/31505/']