Click here to Skip to main content
11,496,146 members (614 online)
Click here to Skip to main content

Tagged as

ASP Control: On Page_Load event, markup control is null

, 21 Aug 2011 CPOL 10.9K 2
This situation is quite tricky and happens when you add a custom control to some page.
The site is currently in read-only mode for maintenance. Posting of new items will be available again shortly.

During page load, all child controls receive the OnLoad event. When you try to access controls defined in the control's markup in the OnLoad method override, all markup controls are NULL.

To solve this mysterious problem, you must register the custom control's tag using its relative URL path like:

<%@ Register Src="~/CustomControls/MediaGalleryPostThumbnail.ascx" 
    TagName="MediaGalleryPostThumbnail" TagPrefix="CC" %>

MediaGalleryPostThumbnail.ascx is the implemented custom control here.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Member 8169684

United States United States
No Biography provided

Comments and Discussions

-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150520.1 | Last Updated 21 Aug 2011
Article Copyright 2011 by Member 8169684
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid