views:

873

answers:

2

I'm writing a custom module for DNN 5, and I need a "Manage" link to be on every control in the module. I created a new UserControl ("ManagerLink") that inherits from PortalModuleBase, put my link into that control, and dropped that control on ALL OF MY MAIN CONTROLS.

The problem is that ModuleId and TabId are always -1 in "ManagerLink" nested control. PortalId works just fine, and I can get a TabId by doing PortalSettings.ActiveTab.TabID.

  1. Why can't I get ModuleId and TabId in from "ManagerLink" control, even though it inherits from PortalModuleBase?

  2. Is there an alternative method to get ModuleId (equivalent of PortalSettings.ActiveTab.TabID)

+4  A: 

William Severance from DNN forum answered this one for me, I'll post the answer here as well.

Since the child control inherits from PortalModuleBase, I would do the following in the Page_Load handler of the parent control

Note: ManagerLink is assumed to be a reference to the child control

VB.NET:

With ManagerLink
    .ModuleConfiguration = Me.ModuleConfiguration
    .LocalResourceFile = Me.LocalResourceFile
End With
C#:
protected void Page_Load(System.Object sender, System.EventArgs e)
{
    ManagerLink.ModuleConfiguration = this.ModuleConfiguration;
    ManagerLink.LocalResourceFile = this.LocalResourceFile
}

The above allows the child control to use the parent's ModuleConfiguration (which will include ModuleId) and LocalResourceFile for any localization.

roman m
A: 

Thanks.. i too had the same issue. resolved using this.

sai kumar