My Cart (0)  |  My Orders  |  My Downloads  |  My Auction  |  My Account  |  Help


Login |Register        Search

How to navigate to another page from dnn custom module

                Print      Add To Favorite     Add To Watch List     Contact Author

Creator: host   8/27/2012 10:31:47 PM    Author: Sibabrata Dash   Source: http://www.mindfiresolutions.com/How-to-navigate-to-another-page-from-DotNetNuke-Custom-module-1099.php   Views: 2955    0    0  
Tags:
navigate Module develop redirect

In some situations, there is a requirement to add functionality that allows users to navigate from one page to another in DotNetNuke  Custom Module. For example, if you have a custom module called "Register"  and the user has successfully registered, you may want to navigate the user to another page to view user login detail where another custom module already been added in order to view login user detail.

In Dotnetnuke module we need the Tab Id of the page in order to navigate to another page.
So to achieve this we can add a dropdown field in Edit page of our custom module(Register) to show all the available Tab/ Page names of DNN website where user can select the Page name to redirect which  internally keeps the Tab Id as value. And later we can use that Tab Id value in order to navigate to other page.

 

[Code in C#]
EditRegister.ascx
//Adding a Dropdown field in EditRegister.ascx page to allow admin or host to select the redirect page name
<asp:DropDownList ID="ddlTabNames" runat="server"></asp:DropDownList>

EditRegister.ascx.cs
//Adding available page names to the dropdown using object of TabController
if (Page.IsPostBack == false)
{
       DotNetNuke.Entities.Tabs.TabController objTabController = new DotNetNuke.Entities.Tabs.TabController();
 
        ArrayList arrlTabs = null;
        arrlTabs = objTabController.GetTabs(this.PortalId);

        string strKey = string.Empty;
        string strValue = string.Empty;

        ddlTabNames.Items.Clear();
 
       //Get the tabname and tabid of each tabs or page using object of TabInfo and added to dropdownlist field
        foreach (Entities.Tabs.TabInfo objTab in arrlTabs)
        {
            strKey = objTab.TabName;
            strValue = objTab.TabID.ToString();

            ddlTabNames.Items.Add(new ListItem(strKey, strValue));
        }
}

       //Using ModuleControler object we need to save selected Page TabId in module specific variable
        ModuleController objController = new ModuleController();
        objController.UpdateModuleSetting(this.ModuleId, "TabID", ddlTabNames.SelectedValue);

ViewRegister.ascx.cs

       //Now From custom module view page we can redirect to another Page or Tab of DNN website using following code

       //Get the selected TabId
       int iProfileTabId = Convert.ToInt32(Settings["TabID"]);

       //Redirect to selected Page
        this.Response.Redirect(Globals.NavigateURL(iProfileTabId), true);


Rating People: 14   Average Rating:     

     DnnModule.com is built to provide DNN quality modules and DNN skins, some of them are free, some not. We wish these stuffs (free or not ) can be useful to you.

     Besides that, we also provide a full range of professional services, ranging from web site build, seo, system management, administration, support, senior consultancy and security services. We act as if your development project or network was ours, with care and respect. We are not satisfied until it works the way you want it to, and we don't silently ignore found issues as somebody else's problem.