Hi,
I havn't worked with the templatecontroll class so i can not answer that question. I do however have some example code for your:
ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ConfigureModule.ascx.cs" Inherits="Leval.Modules.Module.ConfigureModule" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
<td valign="top" width="15%" align="left">
<dnn:Label ID="lblChooseShop" runat="server" suffix=":" />
</td>
<td valign="top" width="85%" align="left">
<asp:DropDownList ID="lstShop" runat="server" AutoPostBack="true"></asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<hr />
</td></tr>
<tr id="trConfig" visible="false" runat="server">
<td valign="top" width="15%" align="left">
<asp:LinkButton ID="hlGeneral" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="general" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlInvoiceing" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="invoiceing" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlSmtp" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="smtp" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlPayment" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="payment" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlTaxZones" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="taxzones" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlShippingMethod" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="shippingmethod" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlShippingZones" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="shippingzones" CssClass="Head"></asp:LinkButton><br />
<asp:LinkButton ID="hlShippingCost" runat="server" OnCommand="goConfigure" CommandName="Swap" CommandArgument="shippingcost" CssClass="Head"></asp:LinkButton><br />
</td>
<td valign="top" width="85%" align="left">
<asp:PlaceHolder ID="plhGeneral" runat="server" Visible="true">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhInvoiceing" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhSmtp" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhPayment" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhTaxZones" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhShippingMethod" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhShippingZones" runat="server" Visible="false">
</asp:PlaceHolder>
<asp:PlaceHolder ID="plhShippingCost" runat="server" Visible="false">
</asp:PlaceHolder>
</td>
</tr>
</table>
.cs file:
namespace Modules.Module
{
partial class ConfigureModule : PortalModuleBase, IModuleConfigure
{
private string _ShopId = "";
private Hashtable CSettings;
private CModuleConfigure ctlGeneral;
private CModuleConfigure ctlInvoiceing;
private CModuleConfigure ctlSmtp;
private CModuleConfigure ctlPayment;
private CModuleConfigure ctlTaxZones;
private CModuleConfigure ctlShippingMethod;
private CModuleConfigure ctlShippingZones;
private CModuleConfigure ctlShippingCost;
#region Event Handlers
protected void Page_Load(Object sender, EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
loadShops();
hlGeneral.Text = Localization.GetString("hlGeneral.Text", this.LocalResourceFile);
hlInvoiceing.Text = Localization.GetString("hlInvoiceing.Text", this.LocalResourceFile);
hlSmtp.Text = Localization.GetString("hlSmtp.Text", this.LocalResourceFile);
hlPayment.Text = Localization.GetString("hlPayment.Text", this.LocalResourceFile);
hlTaxZones.Text = Localization.GetString("hlTaxZones.Text", this.LocalResourceFile);
hlShippingMethod.Text = Localization.GetString("hlShippingMethod.Text", this.LocalResourceFile);
hlShippingZones.Text = Localization.GetString("hlShippingZones.Text", this.LocalResourceFile);
hlShippingCost.Text = Localization.GetString("hlShippingCost.Text", this.LocalResourceFile);
ShowPanels(true, false, false, false, false, false, false, false);
}
_ShopId = lstShop.SelectedValue;
if (_ShopId.Length > 0)
{
loadSettings();
trConfig.Visible = true;
}
else
{
trConfig.Visible = false;
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
protected void goConfigure(Object sender, CommandEventArgs e)
{
switch (e.CommandName.ToLower())
{
case "swap":
switch (e.CommandArgument.ToString().ToLower())
{
case "general":
ShowPanels(true, false, false, false, false, false, false, false);
break;
case "invoiceing":
ShowPanels(false, true, false, false, false, false, false, false);
break;
case "smtp":
ShowPanels(false, false, true, false, false, false, false, false);
break;
case "payment":
ShowPanels(false, false, false, true, false, false, false, false);
break;
case "taxzones":
ShowPanels(false, false, false, false, true, false, false, false);
break;
case "shippingmethod":
ShowPanels(false, false, false, false, false, true, false, false);
break;
case "shippingzones":
ShowPanels(false, false, false, false, false, false, true, false);
break;
case "shippingcost":
ShowPanels(false, false, false, false, false, false, false, true);
break;
}
break;
}
}
#endregion
#region private functions
private void loadShops()
{
RoleController RC = new RoleController();
ModuleShopController CSC = new ModuleShopController();
lstShop.Items.Clear();
lstShop.Items.Add(new ListItem("...", ""));
foreach (ModuleShopInfo CSI in CSC.GetModuleShops(this.PortalId))
{
ModuleShopPermissionController CSPM = new ModuleShopPermissionController();
foreach (ModuleShopPermissionInfo CSPI in CSPM.GetModuleShopPermissionsByShop(CSI.ShopId))
{
if (this.UserInfo.IsInRole(RC.GetRole(CSPI.RoleId, this.PortalId).RoleName))
{
lstShop.Items.Add(new ListItem(CSI.ShopName, CSI.ShopId));
break;
}
}
}
if (_ShopId.Length == 0)
{
lstShop.SelectedIndex = 0;
}
}
private void loadSettings()
{
CSettings = new ModuleSettings(_ShopId).Settings;
loadGeneral();
loadInvoiceing();
loadSmtp();
loadPayment();
loadTaxZones();
loadShippingMethod();
loadShippingZones();
loadShippingCost();
}
private void loadGeneral()
{
plhGeneral.Controls.Clear();
ctlGeneral = (CModuleConfigure)LoadControl(ModulePath + "ConfigureGeneralModule.ascx");
ctlGeneral.ID = "GeneralModule_control";
ctlGeneral.ParentControl = this as PortalModuleBase;
ctlGeneral.CConfigure = this as IModuleConfigure;
ctlGeneral.CSettings = CSettings;
plhGeneral.Controls.Add(ctlGeneral);
}
private void loadInvoiceing()
{
plhInvoiceing.Controls.Clear();
ctlInvoiceing = (CModuleConfigure)LoadControl(ModulePath + "ConfigureInvoiceingModule.ascx");
ctlInvoiceing.ID = "InvoiceingModule_control";
ctlInvoiceing.ParentControl = this as PortalModuleBase;
ctlInvoiceing.CConfigure = this as IModuleConfigure;
ctlInvoiceing.CSettings = CSettings;
plhInvoiceing.Controls.Add(ctlInvoiceing);
}
private void loadSmtp()
{
plhSmtp.Controls.Clear();
ctlSmtp = (CModuleConfigure)LoadControl(ModulePath + "ConfigureSmtpModule.ascx");
ctlSmtp.ID = "SmtpModule_control";
ctlSmtp.ParentControl = this as PortalModuleBase;
ctlSmtp.CConfigure = this as IModuleConfigure;
ctlSmtp.CSettings = CSettings;
plhSmtp.Controls.Add(ctlSmtp);
}
private void loadPayment()
{
plhPayment.Controls.Clear();
ctlPayment = (CModuleConfigure)LoadControl(ModulePath + "ConfigurePaymentModule.ascx");
ctlPayment.ID = "PaymentModule_control";
ctlPayment.ParentControl = this as PortalModuleBase;
ctlPayment.CConfigure = this as IModuleConfigure;
ctlPayment.CSettings = CSettings;
plhPayment.Controls.Add(ctlPayment);
}
private void loadTaxZones()
{
plhTaxZones.Controls.Clear();
ctlTaxZones = (CModuleConfigure)LoadControl(ModulePath + "ConfigureTaxZonesModule.ascx");
ctlTaxZones.ID = "TaxModule_control";
ctlTaxZones.ParentControl = this as PortalModuleBase;
ctlTaxZones.CConfigure = this as IModuleConfigure;
ctlTaxZones.CSettings = CSettings;
plhTaxZones.Controls.Add(ctlTaxZones);
}
private void loadShippingMethod()
{
plhShippingMethod.Controls.Clear();
ctlShippingMethod = (CModuleConfigure)LoadControl(ModulePath + "ConfigureShippingMethodModule.ascx");
ctlShippingMethod.ID = "ShippingMethodModule_control";
ctlShippingMethod.ParentControl = this as PortalModuleBase;
ctlShippingMethod.CConfigure = this as IModuleConfigure;
ctlShippingMethod.CSettings = CSettings;
plhShippingMethod.Controls.Add(ctlShippingMethod);
}
private void loadShippingZones()
{
plhShippingZones.Controls.Clear();
ctlShippingZones = (CModuleConfigure)LoadControl(ModulePath + "ConfigureShippingZonesModule.ascx");
ctlShippingZones.ID = "ShippingZonesModule_control";
ctlShippingZones.ParentControl = this as PortalModuleBase;
ctlShippingZones.CConfigure = this as IModuleConfigure;
ctlShippingZones.CSettings = CSettings;
plhShippingZones.Controls.Add(ctlShippingZones);
}
private void loadShippingCost()
{
plhShippingCost.Controls.Clear();
ctlShippingCost = (CModuleConfigure)LoadControl(ModulePath + "ConfigureShippingCostModule.ascx");
ctlShippingCost.ID = "ShippingCostModule_control";
ctlShippingCost.ParentControl = this as PortalModuleBase;
ctlShippingCost.CConfigure = this as IModuleConfigure;
ctlShippingCost.CSettings = CSettings;
plhShippingCost.Controls.Add(ctlShippingCost);
}
#endregion
#region IModuleConfigure
public void ShowPanels(bool pnlGeneral, bool pnlInvoiceing, bool pnlSmtp, bool pnlPayment, bool pnlTaxZones, bool pnlShippingMethod, bool pnlShippingZones, bool pnlShippingCost)
{
plhGeneral.Visible = pnlGeneral;
plhInvoiceing.Visible = pnlInvoiceing;
plhSmtp.Visible = pnlSmtp;
plhPayment.Visible = pnlPayment;
plhTaxZones.Visible = pnlTaxZones;
plhShippingMethod.Visible = pnlShippingMethod;
plhShippingZones.Visible = pnlShippingZones;
plhShippingCost.Visible = pnlShippingCost;
}
public string ShopId
{
get
{
return _ShopId;
}
}
#endregion
}
}
and the imoduleconfigure type (compiled cs class):
namespace Leval.Modules.Module.Is
{
public interface IModuleConfigure
{
void ShowPanels(bool pnlGeneral, bool pnlInvoiceing, bool pnlSmtp, bool pnlPayment, bool pnlTaxZones, bool pnlShippingMethod, bool pnlShippingZones, bool pnlShippingCost);
string ShopId { get;}
}
}
and one of the strongly typed classes (CModuleConfigure here, also compiled cs class):
namespace Modules.Module.Cs
{
public abstract class CModuleConfigure : CModule_Basis
{
protected IModuleConfigure _CConfigure;
public IModuleConfigure CConfigure
{
get { return _CConfigure; }
set { _CConfigure = value; }
}
}
}
And the basis class to complete it:
namespace Modules.Module.Cs
{
public class CModule_Basis : PortalModuleBase
{
#region Private Declarations
protected PortalModuleBase _ParentControl = new PortalModuleBase();
protected Hashtable _CSettings;
#endregion
#region PortalModuleBase Overrides
protected override void OnLoad(EventArgs e)
{
try
{
this.LocalResourceFile = DotNetNuke.Services.Localization.Localization.GetResourceFile(this, this.GetType().BaseType.Name + ".ascx");
this.ModuleConfiguration = _ParentControl.ModuleConfiguration;
base.OnLoad(e);
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
#endregion
#region Public Properties
public Hashtable CSettings
{
get
{ return _CSettings; }
set
{ _CSettings = value; }
}
public PortalModuleBase ParentControl
{
get { return _ParentControl; }
set { _ParentControl = value; }
}
#endregion
}
}
HTH
Alexander