DNN: Navigate from Module in a Tab to a Module in different Tab

        /// 
        /// Gets the user management URL.
        /// 
        /// The portal id.
        /// 
        protected string GetUserManagementUrl(int portalId)
        {
            int userManagementTabId = GetTabIdForCurrentPortal(AppConfiguration.UserManagementTabName);
            int moduleId = GetModuleId(userManagementTabId, AppConfiguration.UserManagementModuleName);
 
            string[] param = new string[4];
            param[0] = Constants.MODULE_ID_NAME;
            param[1] = moduleId.ToString();
            param[2] = Constants.PORTAL_ID_PARAMETER;
            param[3] = portalId.ToString();
 
            DotNetNuke.Common.Globals.ApplicationURL();
 
            return DotNetNuke.Common.Globals.NavigateURL(userManagementTabId, AppConfiguration.UserManagementControlName, param);
        }

        /// 
        /// Gets the tab id for current portal.
        /// 
        /// Name of the tab.
        /// 
        protected virtual int GetTabIdForCurrentPortal(string tabName)
        {
            TabController tabController = new TabController();
            TabInfo tabInfo = tabController.GetTabByName(tabName, PortalId);
            return tabInfo.TabID;
        }
 
        /// 
        /// Gets the tab id for portal.
        /// 
        /// Name of the tab.
        /// The portal id.
        /// 
        protected virtual int GetTabIdForPortal(string tabName, int portalId)
        {
            TabController tabController = new TabController();
            TabInfo tabInfo = tabController.GetTabByName(tabName, portalId);
            return tabInfo.TabID;
        }
 
        /// 
        /// Gets the module id.
        /// 
        /// The tab id.
        /// Name of the module.
        /// 
        protected virtual int GetModuleId(int tabId, string moduleName)
        {
            ModuleController moduleController = new ModuleController();
            Dictionary<int, ModuleInfo> genericModuleInfos = moduleController.GetTabModules(tabId);
            ModuleInfo selectedModule = null;
 
            foreach (KeyValuePair<int, ModuleInfo> pair in genericModuleInfos)
            {
                if (pair.Value.ModuleName.Equals(moduleName, StringComparison.InvariantCultureIgnoreCase))
                    selectedModule = pair.Value;
            }
 
            if (selectedModule != null)
                return selectedModule.ModuleID;
            return -1;
        }
 
        /// 
        /// Gets the user count for the passed in portal id.
        /// 
        /// The portal id.
        /// 
        protected virtual int GetPortalUserCount(int portalId)
        {
            MembershipProvider membershipProvider = MembershipProvider.Instance();
            return membershipProvider.GetUserCountByPortal(portalId);
        }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s