Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Navigating to a module on different page...Navigating to a module on different page...
Previous
 
Next
New Post
10/26/2009 7:21 AM
 

Hi William,

Thank you for your hints - they helped to get the code working. (That was a long day here yesterday and I missed to "dig out" TabController and ModuleController classes, and also mixed up ModuleDefinitionInfo with ModuleInfo). Yes, I do investigate DNN API by running my sample site under debugger. I must say I had expected such methods would have been already there in DNN core, and I had also expected that TabController and ModuleController could have had static methods to find ID of certain Tab or Module within a tab given TabName and ModuleName...

Anyway, the code is working now. And I'm happy :)

Here is this code:


/// <summary>
/// Navigates to current module own view control
///  given this control's key <paramref name="controlKey"/>
/// </summary>
/// <param name="currentModuleInstance">Current module instance,
///    see <see cref="PortalModuleBase"/></param>
/// <param name="controlKey">A key of view control to navigate to</param>
public void NavigateToCurrentModuleViewControl(
    PortalModuleBase currentModuleInstance,
    string controlKey)
{
    int tabId = currentModuleInstance.TabId; ;
    string thisModuleIdAsAdditionalParameter =
            string.format("mid={0}", this.ModuleId);
    currentModuleInstance.Page.Response.Redirect(
        DotNetNuke.Common.Globals.NavigateURL(
         tabId,
         controlKey,
         thisModuleIdAsAdditionalParameter));
}

/// <summary>
/// Gets TabId by its tab-/page-name
/// </summary>
/// <param name="portalId">Portal Id</param>
/// <param name="tabName">Tab Name</param>
/// <returns>TabId if tabName belongs to an exiting page, -1 otherwise</returns>
/// <remarks>
/// 1. This method skips hidden pages.
/// </remarks>
public int GetTabIdByTabName(int portalId, string tabName)
{
    DotNetNuke.Entities.Tabs.TabInfo tabInfo =
      (new DotNetNuke.Entities.Tabs.TabController()).
       GetTabByName(tabName, portalId);  
    if (tabInfo != null) return tabInfo.TabID;
    throw new ApplicationException(
        string.format("Can't get TabId for given Portalid={0} and TabName='{1}'", portalId, tabName));
}

/// <summary>
/// Gets ModuleId by module name
/// </summary>
/// <param name="tabId">Tab Id</param>
/// <param name="moduleName">Module name</param>
/// <returns>ModuleId if given module name corresponds to an
/// installed module, throws <see cref="ApplicationException"/>
/// otherwsie.
/// </returns>
public int GetModuleIdByName(int tabId, string moduleName)
{
    DotNetNuke.Entities.Modules.ModuleController moduleController =
        new ModuleController();
    Dictionary<int, ModuleInfo> tabModules =
      (new DotNetNuke.Entities.Modules.ModuleController()).
         GetTabModules(tabId);
    foreach (ModuleInfo moduleInfo in tabModules.Values)
        if (string.Compare(moduleInfo.ModuleName, moduleName, true) == 0)
            return moduleInfo.ModuleID; 
    throw new ApplicationException
        (string.format("Can't get ModuleId for given module name '{0}'",
          moduleName));
}

/// <summary>
/// Navigates to other tab's module view control
///  given <paramref name="tabName"/>, <paramref name="moduleName"/> and
///  target control's <paramref name="controlKey"/>
/// </summary>
/// <param name="currentModuleInstance">Current module instance,
///    see <see cref="PortalModuleBase"/></param>
/// <param name="tabName">Tab Name</param>
/// <param name="moduleName">Module Name</param>
/// <param name="controlKey">A key of view control to navigate to</param>
public void NavigateToOtherTabModuleViewControl(
    PortalModuleBase currentModuleInstance,
    string tabName,
    string moduleName,
    string controlKey)
{
    int portalId = currentModuleInstance.PortalId;
    int tabId = GetTabIdByTabName(portalId, tabName);
    int moduleId = GetModuleIdByName(tabId, moduleName);

    string moduleIdAsAdditionalParameter =
            string.format("mid={0}", moduleId);
    currentModuleInstance.Page.Response.Redirect(
       DotNetNuke.Common.Globals.NavigateURL(
        tabId,
        controlKey,
        moduleIdAsAdditionalParameter), true);
}

 

Intended usage of the above code:

        string tabName = "Test";
        string moduleName = "YourCompany.TestModule";
        string controlKey = "DetailedInfoViewControl";

        NavigateToOtherTabModuleViewControl(this, tabName, moduleName, controlKey); 

Thank you.

--Shamil

 

 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...Navigating to a module on different page...Navigating to a module on different page...


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out