1

I am new in DotnetNuke. I don't know all the terminology of DotnetNuke. Please correct me. That will help me to improve.

I have create a Simple Project with 2 UserControl. 1- View.ascx, 2- ModuleInfo.ascx

1- View.ascx: It contains a button. I want to redirect it to another User Control ModuleInfo.ascx Here is code.

protected void btn1_Click(object sender, EventArgs e)
{
    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL("ModuleInfo"), true);
}

2- ModuleInfo.ascx It contains static table.

How I added Module to DotnetNuke:

1- Add .zip file of build project to Admin --> Extension
2- Edit Module from Host --> Extension --> Edit Module --> Edit Definition --> Add Module Control --> Added key "ModuleInfo" and selected view.
3- Created new page and added module to it. 

When page load, View.aspx is fine. There is a button. But when I click on button, it will redirect to some page but it is blank. It should show the Table.

Can anybody please suggest me if I am missing anything here?

Nanji Mange
  • 2,155
  • 4
  • 29
  • 63

1 Answers1

2

NavigateUrl must include tabId and moduleId in the additional arguments in order to work. A simpler method for navigating to views inside your module is simply use the base.EditUrl() which only needs the view's controlKey. See the below code snippet, both lines that set miUrl are equivalent.

protected void btn1_Click(object sender, EventArgs e)
{
    string miUrl = base.EditUrl("ModuleInfo");
    string miUrl = DotNetNuke.Common.Globals.NavigateURL(base.TabId, "ModuleInfo", String.Format("mid={0}", base.ModuleId));

    Response.Redirect(miUrl, true);
}
Fix It Scotty
  • 2,852
  • 11
  • 12
  • It is working fine. How can I redirect to another module? i.e. I am on Module Test1 and I want to redirect to Module Test2. In this case there will be no Key. Please suggest – Nanji Mange Nov 07 '16 at 10:33
  • 1
    Nanji, in order to navigate to another module view that is from a different module definition, you need to know both the ModuleId and TabId and you can use the NavigateUrl() like above. Typically, you would add a module setting for the administrator to select the module & page where they want to redirect. Getting a list of all modules instances using the module definition name can be done with the ModuleController.GetModulesByDefinition(). – Fix It Scotty Nov 07 '16 at 13:58