I'm a DotNetNuke newbie. Please be gentle. I'm using the "DotNetNuke 6 Compiled Module" template to build my module. I already have View.ascx control in the project and have added another control called test.ascx.
My question is: how do I show different different views in different pages I add the module to. (if that is possible at all) e.g Show View.ascx on say the default.aspx page and then on the default2.aspx page show the test.ascx user control?
If this is not possible does it mean I need different visual studio projects for each ascx control. Surely not.
Astro,
Option 1:
You need to go to Host > Extensions > Edit your extesion > Expand Module definition and click on add control.
Here you have to select your ascx control and provide key as any string. Let's say you provided key test
, you selected user control and selected control type as view
and saved it.
Now from view you can use following code to navigate to the newly added control:
DotNetNuke.Common.Globals.NavigateUrl(TabId,"test","mid="+ModuleID);
This will redirect the page and load your page with test.ascx.
You can use this kind of option when you want to show view.ascx by default and want to switch view when on some action and show test.ascx. Disadvantage here is, when you switch to test.ascx, all other modules added to page will not be visible.
Option 2:
You have to create a new definition in module. For that go to Host > Extensions > Edit Your module > Expand Module Definitoins > Click on add and add new definition. Once definition is added, you can add your test.ascx and view control to the definition without any key.
Once above is done, if you delete and add your module to page again, it will show two modules added in the page. These are two definitions. Look at the blog module definition for example of how multiple definitions works.
This option is used when you want to show multiple view control at the same time from the same module.
I hope this helps. Let me know if you have any more questions.