I am a big fan of Scott's modules and I have adapted his approach to module navigation in several of my own DNN 2 modules that work just fine. My problem is trying to convert my modules over to DNN 3. I am a newbie to .net coding and learning by example so please excuse any stupid questions.
Below is the code I use in DNN 2 to load user controls within a module and this works fine in DNN 2.1.2
DNN 2 Code
Private Sub LoadControlType()
Dim objPortalModuleControl As PortalModuleControl = CType(Me.LoadControl(m_controlToLoad), PortalModuleControl)
objPortalModuleControl.ModuleConfiguration = Me.ModuleConfiguration
plhControls.Controls.Add(objPortalModuleControl)
End Sub
DNN 3 Conversion Code
Private Sub LoadControlType()
Dim objPortalModuleControl As DotNetNuke.Entities.Modules.PortalModuleBase = CType(Me.LoadControl(m_controlToLoad), DotNetNuke.Entities.Modules.PortalModuleBase)
objPortalModuleControl.ModuleConfiguration = Me.ModuleConfiguration
plhControls.Controls.Add(objPortalModuleControl)
End Sub
The above conversion code gives the following error:
Unhandled error loading module.
DotNetNuke.Services.Exceptions.ModuleLoadException: Unhandled Error Adding Module to TopPane ---> System.InvalidCastException: Specified cast is not valid. at BusinessWebPortals.Modules.Cinema.MovieTime.LoadControlType() in C:\Inetpub\DNN3\DesktopModules\Cinema\MovieTime.ascx.vb:line 214 at BusinessWebPortals.Modules.Cinema.MovieTime.Page_Init(Object sender, EventArgs e) in C:\Inetpub\DNN3\DesktopModules\Cinema\MovieTime.ascx.vb:line 73 at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) in C:\Inetpub\DNN3\admin\Skins\Skin.vb:line 727 --- End of inner exception stack trace ---
If anyone could shed some light on this problem I would appreciate the help. I don't know if I am using the correct class on the conversion or not.
Scott if you happen to read this post I would like to thank you for creating the excellent modules you have. I have learned a great deal from your experience. I am a long long long way from understanding only a fraction of what you do in you modules. Thank again. If you could help in any way it would be nice.