Sorry, it didn't work - still can't navigate to a page with given name to have its certain module opened a certain (view) control. It is probably not possible at all? Please advise - below are code snippets, which almost work as required:
/// <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)
{
int tabId = -1;
//?tabId = DotNetNuke.Entities.Tabs.TabController.GetTabByTabPath(portalId, tabName);
List<DotNetNuke.Entities.Tabs.TabInfo> tabs = DotNetNuke.Entities.Tabs.TabController.GetPortalTabs(portalId, -1, false, false);
foreach (DotNetNuke.Entities.Tabs.TabInfo tabInfo in tabs)
if (string.Compare(tabInfo.TabName, tabName, true) == 0)
return tabInfo.TabID;
return tabId;
}
/// <summary>
/// Gets ModuleId by module friednly name
/// </summary>
/// <param name="moduleFriendlyName">Module Friendly name</param>
/// <returns>ModuleId if given module friendly name corresponds to an
/// installed module, throws <see cref="ApplicationException"/>
/// otherwsie.
/// </returns>
public int GetModuleIdByFriendlyName(string moduleFriendlyName)
{
//?DotNetNuke.Entities.Modules.Definitions.ModuleDefinitionInfo info =
// DotNetNuke.Entities.Modules.Definitions.ModuleDefinitionController.GetModuleDefinitionByFriendlyName
// (moduleFriendlyName);
Dictionary<int, DotNetNuke.Entities.Modules.Definitions.ModuleDefinitionInfo> dictionary =
DotNetNuke.Entities.Modules.Definitions.ModuleDefinitionController.GetModuleDefinitions();
foreach (DotNetNuke.Entities.Modules.Definitions.ModuleDefinitionInfo info in dictionary.Values)
if (string.Compare(info.FriendlyName, moduleFriendlyName, true) == 0)
return info.DesktopModuleID;
throw new ApplicationException
(string.format("Can't get ModuleId for given module friednly name '{0}'",
moduleFriendlyName));
}
/// <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 NavigateToOtherTabModuleViewControl(
PortalModuleBase currentModuleInstance,
string tabName,
string moduleFriendlyName,
string controlKey)
{
int portalId = this.PortalId;
int tabId = GetTabIdByTabName(portalId, tabName);
int moduleId = GetModuleIdByFriendlyName(moduleFriendlyName);
string moduleIdAsAdditionalParameter =
string.format("mid={0}", moduleId);
// it doesn't work -
// currentModuleInstance.Page.Response.Redirect(
// DotNetNuke.Common.Globals.NavigateURL(
// tabId,
// controlKey,
// moduleIdAsAdditionalParameter), true);
currentModuleInstance.Page.Response.Redirect(
DotNetNuke.Common.Globals.NavigateURL(
tabId), true);
}
Thank you.
--Shamil