Hello,
(I realize this is a long and detailed post, but I think it is a very basic requirement in developing modules to be able to do a master/detail and I have not found any documentation on this at all. So I think it would be a worthwhile solution to document to enable other developers, so I hope those of you that are capable of answering, do so to help enable the continual proliferation of DNN :) )
I am new to module development. I am creating a classic Master/Detail module where the master contains a gridview that is filterable by the user, then the user can click on a row to go to the details view. I have created 3 controls to handle this:
1.) view.ascx which plays traffic cop and displays either the search.ascx or the details.ascx
2.) search.ascx which allows the user to search data and display summary results
3.) details.ascx which is displayed when the user clicks a link on the gridview for a particular row in the search.ascx
The hard part is done in creating the search.ascx and the details.ascx. But I am having problems with the traffic cop control, view.ascx.
I have tried the following approaches:
1.) Dynamically load the controls as such:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TheDynoRoom.ascx.vb" Inherits=".TheDynoRoom" %>
<
asp:PlaceHolder
ID
=
"phViewControl"
runat
=
"server"
EnableViewState
=
"False"
/>>
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
Call
LoadDynamicControl()
End
Sub
Public
Sub
LoadDynamicControl()
Dim
controlToLoad
As
Control
Try
Dim
DynoRunID
As
Integer
= Convert.ToInt32(Request.QueryString(
"ID"
))
controlToLoad =
Me
.LoadControl(
"Controls/DynoSearch.ascx"
)
If
DynoRunID > 0
Then
controlToLoad =
Me
.LoadControl(
"Controls/MyGarage.ascx"
)
End
If
Me
.Controls.Add(controlToLoad)
phViewControl.Controls.Add(controlToLoad)
Catch
exc
As
Exception
'Module failed to load
ProcessModuleLoadException(
Me
, exc)
End
Try
End
Sub
This started giving me problems. The first was with a ViewState error, so I turned the EnableViewState to False just to get past it. Next I was getting "
Cannot unregister updatepanel" errors due to dynamically loading/unloading controls that have ajax modal popups. So I tried method 2:
2.) Show and Hide Panels each with its own control. So I created a Search panel and a Details panel and use logic to show/hide each. This works fine when I run it in visual studio, but has issues when I install and run within DNN. Here is the code:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="TheDynoRoom.ascx.vb" Inherits=".TheDynoRoom" %>
<%@ Register src="Controls/DynoSearch.ascx" tagname="DynoSearch" tagprefix="uc1" %>
<%@ Register src="Controls/MyGarage.ascx" tagname="MyGarage" tagprefix="uc2" %>
<
asp:Panel
ID
=
"pnlSearch"
runat
=
"server"
>
<
uc1:DynoSearch
ID
=
"DynoSearch"
runat
=
"server"
/>
</
asp:Panel
>
<
asp:Panel
ID
=
"pnlDetails"
runat
=
"server"
>
<
uc2:MyGarage
ID
=
"MyGarage"
runat
=
"server"
/>
</
asp:Panel
>
01.
Imports
DotNetNuke
02.
Public
Class
TheDynoRoom
03.
Inherits
System.Web.UI.UserControl
04.
05.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
06.
07.
Call
ShowPanel()
08.
09.
End
Sub
10.
11.
Public
Sub
ShowPanel()
12.
13.
Try
14.
15.
If
Request.QueryString.Count > 0
Then
16.
pnlDetails.Visible =
True
17.
pnlSearch.Visible =
False
18.
Else
19.
pnlDetails.Visible =
False
20.
pnlSearch.Visible =
True
21.
End
If
22.
23.
Catch
exc
As
Exception
'Failure
24.
ProcessModuleLoadException(
Me
, exc)
25.
End
Try
26.
End
Sub
27.
End
Class
This produces the following error in DNN upon trying to render the module:
ModuleId: 1139
ModuleDefId: 287
FriendlyName: The Dyno Room
ModuleControlSource: DesktopModules/Incite/TheDynoRoom.ascx
AssemblyVersion: 5.5.1
PortalID: 0
PortalName: TheDynoRoom.com
UserID: 1
UserName: host
ActiveTabID: 453
ActiveTabName: Test Module 2
RawURL: /dynodnn/TestModule2.aspx
AbsoluteURL: /DynoDNN/Default.aspx
AbsoluteURLReferrer: http://localhost/dynodnn/TestModule2.aspx
UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; GTB6.6; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; OfficeLiveConnector.1.5; OfficeLivePatch.1.3; .NET4.0C; .NET4.0E) chromeframe/8.0.552.224
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 3b6e31f2-c1f9-4f65-aa65-109fdc585b51
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl
StackTrace:
Message: DotNetNuke.Services.Exceptions.ModuleLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Modules.ModuleHost.LoadModuleControl() --- End of inner exception stack trace ---
Source:
In attempting to debug, the debugger (VS attach to process) doesn't stop at the page_load or page_init on the view.ascx traffic cop page. Yes, I have deployed the pdb and if I go into the module definitions and select the search.ascx page as the one to load for the view control, it does stop at break points. So it's like its erring out before it even gets to Page_Init??? I thought maybe the path to my Register statements were the issue, but I tried changing them and then DNN came back with a more specific error about not being able to find them, so it doesn't seem to be that...so I am stumped on what is causing the issue.
Questions:
1.) what is the suggested method (show/hide panels vs dynamic load of controls) out of the 2 I've tried (or is there another, (consider point 4 below))? I'd think dynamically loading controls so as to not have both in memory???
2.) Any ideas on how to correct the "
Cannot unregister UpdatePanel error"? when dynamically loading controls?
3.) Any clue as to why LoadModule is bombing and why I can't even trace it in the debugger?
4.) Next I want the Details.ascx to be only visible by registered users but the search can be visible by any website visitor...given that, I think there may be a more desired approach by making the search and details to separate modules that can then have different security access settings. So how would you begin to link to the details.ascx from the search.ascx?
Thanks in advance for any help provided!
Chad