How can I load an embedded resource as an ITemplate? The LoadTemplate() method only takes a string virtual path, and obviously this will not work for embedded resources.
Your control should look like it:
public class Con : Control
{
public Template Content { get; set; }
protected override void CreateChildControls()
{
base.CreateChildControls();
Content = new Template();
// load controls from file and add to this control
Content.InstantiateIn(this);
}
public class Template : ITemplate
{
public void InstantiateIn(Control container)
{
// load controls
container.Controls.Add((HttpContext.Current.Handler as Page).LoadControl("Emb.ascx"));
}
}
}
Then the embedded file:
<%@ Control Language="C#" %>
Then when using the control it will load the embedded resource, so using:
<%@ Register Assembly="TestWeb" Namespace="TestWeb" TagPrefix="c" %>
Will create a TextBox.
If you are trying to access a file inside a DLL, see this implementation of VirtualPathProvider.