DNN: Cannot hit Page_Load event of Control

If you are developing a DotNetNuke module and are in the middle of coding and testing that module within a DNN installation and have noticed that you cannot get Visual Studio to enter the Page_Load event of your User Controls and its driving you insane!

Here is the simple solution, make sure your module definition has the Cache Time set to 0. I have found that this is most likely the reason you never see the Page_Load or any other initialization methods hit when debugging your module.

0

DNN: Navigating Within a Module

Here are several methods which can be used to navigate between controls within a DotNetNuke module.

#region Navigation Methods
 
/// 
/// Redirects to module view.
/// 
protected virtual void RedirectToModuleView()
{
    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(), true);
}
 
/// 
/// Gets the module control URL.
/// 
/// Name of the control.
/// 
protected virtual string GetModuleControlUrl(Enum controlName)
{
    string[] param = new string[2];
    param[0] = MODULE_ID_KEY;
    param[1] = ModuleId.ToString();
 
    return DotNetNuke.Common.Globals.NavigateURL(TabId, controlName.ToString(), param);
}
 
/// 
/// Gets the module control URL.
/// 
/// Name of the control.
/// Name of the parameter.
/// The parameter value.
/// 
protected virtual string GetModuleControlUrl(Enum controlName, string parameterName, int parameterValue)
{
    return GetModuleControlUrl(controlName, parameterName, parameterValue.ToString());
}
 
/// 
/// Gets the module control URL.
/// 
/// Name of the control.
/// Name of the parameter.
/// The parameter value.
/// 
protected virtual string GetModuleControlUrl(Enum controlName, string parameterName, string parameterValue)
{
    string[] param = new string[4];
    param[0] = MODULE_ID_KEY;
    param[1] = ModuleId.ToString();
    param[2] = parameterName;
    param[3] = parameterValue;
 
    return DotNetNuke.Common.Globals.NavigateURL(TabId, controlName.ToString(), param);
}
 
/// 
/// Gets the module control URL.
/// 
/// Name of the control.
/// The parameters.
/// 
protected virtual string GetModuleControlUrl(Enum controlName, string[] parameters)
{
    List<string> param = new List<string>();
    param.Add(MODULE_ID_KEY);
    param.Add(ModuleId.ToString());
    param.AddRange(parameters);
 
    return DotNetNuke.Common.Globals.NavigateURL(TabId, controlName.ToString(), param.ToArray());
}
 
#endregion

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);
        }

DNN Adding Module Help

To add help text to the automatically created ‘Help’ link which DNN adds to each of your custom modules you simply need to add a new ‘Resource Key’ to the control’s .RESX file. For example you may have a View.aspx control which is the default display control for your module. Simply click on the designer surface in visual studio for that control, go to Tools > Generate Local Resource. A new .RESX file will be created in your module’s ‘App_LocalResources’ folder. In this file add a new key ‘ModuleHelp.Text’ and set its text value to the text you want to show up in the help control when it opens. The value you give this key can be plain text or html.

DotNetNuke Navigation Between Tabs (Pages)

To navigate to another page from within one of your modules use the following code:

using DotNetNuke.Common;
using DotNetNuke.Services.Exceptions;
using DotNetNuke.Entities.Tabs;

protected void lbtnVictorianCross_Click(object sender, EventArgs e)
        {
            TabController tabController = new TabController();
            TabInfo tabInfo = tabController.GetTabByName("Unparalleled Valour", PortalId);
            Response.Redirect(Globals.NavigateURL(tabInfo.TabID));
        }