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

DNN Admin Control Styling

This is a simple, clean style for use in the admin sections of DotNetNuke controls.

#promotionalSpace { width:100%; font-family:Arial; text-align:left; margin-bottom:15px; }
    #promotionalSpace .shadow { width:100%; text-align:center; padding:20px 0; }
    #promotionalSpace .container {width:600px; background-color:#ffffff; text-align:left; margin:0 auto; border:solid 1px #E9E9E9; }   
    #promotionalSpace #navigation { width:600px; height:30px; margin-bottom:20px; }
    #promotionalSpace #navigation .link { padding:5px; float:left; }
    #promotionalSpace h3 { font-size:16px; font-weight:bold; }
    #promotionalSpace h4 { font-size:15px; font-weight:bold; }
    #promotionalSpace h5 { font-size:14px; font-weight:bold; }
    #promotionalSpace h6 { font-size:13px; font-weight:bold; background-color:#E9E9E9; margin:5px; padding:5px; }
    #promotionalSpace .Success { color:#339900; background-color:#ccffcc; padding:2px; border:dashed 1px #339900; margin:10px; }
    #promotionalSpace .Error { color:Red; background-color:#ffffcc; padding:2px; border:dashed 1px red; margin:10px; }
    #promotionalSpace .Message { color:Blue; background-color:#D0EDFC; padding:2px; border:dashed 1px blue; margin:10px; }
    #promotionalSpace .button { padding:2px; margin:3px; border:solid 2px #A9D6FD; color:blue; background-color:#D2E7F9; text-decoration:none; display:inline-block; }
        #promotionalSpace .button:hover { color:blue; background-color:#A9D6FD; }
    #promotionalSpace #title { width:100%; height:30px; background-color:#EDF3FE; padding:10px 0; margin-bottom:10px; }
        #promotionalSpace #title h3 { color:#000; padding:5px; margin:0; }
    #promotionalSpace #content { width:100%;  }
        #promotionalSpace #content .control { width:100%; margin:3px; }
        #promotionalSpace #content .spacer { width:100%; height:20px; }
        #promotionalSpace #content .left { text-align:left; }

#promotionTemplate { width:156px; border:solid 1px #A9D6FD; float:left; margin:5px; padding:2px; background-color:#D2E7F9; text-align:center; }
    #promotionTemplate .box { width:154px; background-color:#ffffff; margin:0 auto; text-align:left; }
    #promotionTemplate .clear { clear:both; }
    #promotionTemplate .thumbnail { width:150px; height:150px; margin:2px; }
    #promotionTemplate .details { width:150px; padding:2px; }
        #promotionTemplate .details .control { width:100%; margin:3px; }