[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1201
  • Last Modified:

how to navigate from one control to another in a dotnetnuke module

I am developing a module HK in dotnetnuke.
It has controls as EditModulename.ascx,ViewModulename.ascx and New1.ascx.
This module is on home page, when i run this it shows the ViewModulename.ascx control on home page.
Now i have one link button cmdL1, I want to display a New1.ascx control after clicking on cmdL1 button. How can i do this?

I tried as follows but it didn't work. it gives error
as below

Error: New is currently unavailable.
DotNetNuke.Services.Exceptions.ModuleLoadException: Unable to cast object of type 'ASP.desktopmodules_hk_new1_ascx' to type 'DotNetNuke.Entities.Modules.PortalModuleBase'. ---> System.InvalidCastException: Unable to cast object of type 'ASP.desktopmodules_hk_new1_ascx' to type 'DotNetNuke.Entities.Modules.PortalModuleBase'. at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) --- End of inner exception stack trace ---
Thank You.
Protected Sub cmdL1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdL1.Click
            Dim objModules As ModuleController = New ModuleController
            Response.Redirect(NavigateURL(PortalSettings.ActiveTab.TabID, "New1", "mid=" & CStr(ModuleId)))
        End Sub

Open in new window

  • 2
1 Solution

To navigate to a different user control from bunch of controls in your dotnetnuke module, you need to know the key for that user control that you gave while installing the module

For navigating to specific control in your module (you must have given it some key), you must need a key. To see what key you have given, go to module definitions page, click the edit button beside your module and look at the key it has for example it has key "abcd" without the quotes, then to go to that user control from any other control in that module, you have to do

Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "abcd", "mid=" + ModuleId.ToString()));

where abcd is the module key, ad moduleid you can get it as its a global variable in your control.

Let me know if it is confusing, I'll explain in detail.
madhav_ghatoleAuthor Commented:
I have already given key "New1" to the control New1.ascx
and tried

            Response.Redirect(Globals.NavigateURL(PortalSettings.ActiveTab.TabID, "New1", "mid=" & CStr(ModuleId)))

But it gives error as below, how can I solve this?
aww I was expecting an 'A'  however, note that you have a error on the page, which says one or more module did not load. Get rid of that error and you should be fine.

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now