This is going to depend on when/how you load the control. For example, if you load the control directly in the template
Code:
<%@ Register TagPrefix="Custom" TagName="Control" Src="~/controls/CustomControl.ascx" %>
...
...
...
<Custom:Control ID="cControl" runat="server" />
and then in your control have something like this:
.ascx
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="AspDotNetStorefront.Controls.CustomControl" %>
(!XmlPackage Name="news.xml.config"!)
.ascx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AspDotNetStorefront.Controls
{
public partial class CustomControl : System.Web.UI.UserControl
{
}
}
the Parser will pick up on the token and render it appropriately. Now if you are loading it somewhere programmatically (eg. LoadControl("~/controls/CustomControl.ascx"); or by adding it to an .aspx webpage), then the Parser will have already fired and the token will render as plain text.
The easiest thing to do would just be to create a simple custom control that can execute the xmlpackages and then use this control in all of your other custom controls any time you need an xmlpackage. First the XmlPackage custom control:
.ascx
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="XmlPackage.ascx.cs" Inherits="AspDotNetStorefront.Controls.XmlPackage" %>
<asp:Literal ID="lit1" runat="server" Mode="PassThrough" />
.ascx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspDotNetStorefrontCore;
namespace AspDotNetStorefront.Controls
{
public partial class XmlPackage : System.Web.UI.UserControl
{
public String Name { get; set; }
protected override void OnLoad(EventArgs e)
{
SkinBase sb = Page as SkinBase;
if (Name.Length != 0 && Name.Contains("xml.config"))
{
lit1.Text = AppLogic.RunXmlPackage("news.xml.config", sb.GetParser, sb.ThisCustomer, sb.SkinID, String.Empty, String.Empty, true, true);
}
base.OnLoad(e);
}
}
}
And then, utilizing the above custom control:
.ascx
Code:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="AspDotNetStorefront.Controls.CustomControl" %>
<%@ Register TagPrefix="Custom" TagName="XmlPackage" Src="~/controls/XmlPackage.ascx" %>
<Custom:XmlPackage Name="news.xml.config" runat="server" />
.ascx.cs
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace AspDotNetStorefront.Controls
{
public partial class CustomControl : System.Web.UI.UserControl
{
}
}