Last post Apr 08, 2012 10:03 PM by Decker Dong - MSFT
Apr 07, 2012 12:06 AM|udayr|LINK
I wanted to load a custom control in to a User Control.
public EmailTemplate(string templateLocation)
Page p = new Page();
_template = (EmailTemplateBase)p.LoadControl(templateLocation);
I am passing template location as "~/MyEmailTemplate.ascx"; ( This user control is placed in the application root folder)
I have used the some code in many projects and works. When i try to load the custom control, It says "object reference not found".
(_template in the above code snippet returns null).
I believe the way i specify the "custom control" path is right.
I am stuck with this for hours and hours.
I appreciate any suggestions to resolving this issue.
Apr 07, 2012 02:53 AM|sanjayverma_mca|LINK
Before using the custom control on the page you have to register it .
<%@ Register Src="~/Controls/LoginHeader.ascx" TagName="Login" TagPrefix="uc1" %>
and then you can use it like this
<uc1:Login ID="login2" runat="server" />
on your aspx page .
Apr 08, 2012 10:03 PM|Decker Dong - MSFT|LINK
Before using this control，you should register it by dragging and dropping your own customized control onto the page to generate a statement of registering，and then do your codes to continue……