当前文件路径:DNN/Library/Controls/SectionHeadControl.vb 
1
'
2
' DotNetNuke?- http://www.dotnetnuke.com
3
' Copyright (c) 2002-2008
4
' by DotNetNuke Corporation
5
'
6
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
7
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
8
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
9
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
'
11
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
12
' of the Software.
13
'
14
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
15
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
16
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
17
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18
' DEALINGS IN THE SOFTWARE.
19
'
20
Imports System.IO
21
22
Namespace DotNetNukeNamespace DotNetNuke.UI.UserControls
23
24
/**/''' -----------------------------------------------------------------------------
25
''' <summary>
26
''' SectionHeadControl is a user control that provides all the server code to allow a
27
''' section to be collapsed/expanded, using user provided images for the button.
28
''' </summary>
29
''' <remarks>
30
''' To use this control the user must provide somewhere in the asp page the
31
''' implementation of the javascript required to expand/collapse the display.
32
''' eg:
33
''' function __dnn_SectionMaxMin(img, objID) {
34
''' //implemenation code
35
''' ....
36
''' }
37
''' where __dnn_SectionMaxMin is the name of function, that is supplied
38
''' in the Attribute/Property javaScript.
39
''' </remarks>
40
''' <history>
41
''' [cnurse] 9/7/2004 Created
42
''' </history>
43
''' -----------------------------------------------------------------------------
44
Public Class SectionHeadControlClass SectionHeadControl
45
Inherits System.Web.UI.UserControl
46
47
Controls#Region "Controls"
48
49
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
50
Protected WithEvents imgIcon As System.Web.UI.WebControls.ImageButton
51
Protected WithEvents pnlRule As System.Web.UI.WebControls.Panel
52
53
#End Region
54
55
Private Members#Region "Private Members"
56
57
Private _includeRule As Boolean = False
58
Private _isExpanded As Boolean = True
59
Private _javaScript As String = "__dnn_SectionMaxMin"
60
Private _maxImageUrl As String = "images/plus.gif"
61
Private _minImageUrl As String = "images/minus.gif"
62
Private _resourceKey As String
63
Private _section As String 'Associated Section for this Control
64
65
#End Region
66
67
Public Properties#Region "Public Properties"
68
69
/**/''' -----------------------------------------------------------------------------
70
''' <summary>
71
''' CssClass determines the Css Class used for the Title Text
72
''' </summary>
73
''' <value>A string representing the name of the css class</value>
74
''' <remarks>
75
''' </remarks>
76
''' <history>
77
''' [cnurse] 9/7/2004 Created
78
''' </history>
79
''' -----------------------------------------------------------------------------
80
Public Property CssClass()Property CssClass() As String
81
Get
82
Return lblTitle.CssClass
83
End Get
84
Set(ByVal Value As String)
85
lblTitle.CssClass = Value
86
End Set
87
End Property
88
89
/**/''' -----------------------------------------------------------------------------
90
''' <summary>
91
''' IncludeRule determines whether there is a horizontal rule displayed under the
92
''' header text
93
''' </summary>
94
''' <value>A string representing true or false</value>
95
''' <remarks>
96
''' </remarks>
97
''' <history>
98
''' [cnurse] 9/7/2004 Created
99
''' </history>
100
''' -----------------------------------------------------------------------------
101
Public Property IncludeRule()Property IncludeRule() As Boolean
102
Get
103
Return _includeRule
104
End Get
105
Set(ByVal Value As Boolean)
106
_includeRule = Value
107
End Set
108
End Property
109
110
/**/''' -----------------------------------------------------------------------------
111
''' <summary>
112
''' IsExpanded determines whether the section is expanded or collapsed.
113
''' </summary>
114
''' <value>Boolean value that determines whether the panel is expanded (true)
115
''' or collapsed (false). The default is true.</value>
116
''' <remarks>
117
''' </remarks>
118
''' <history>
119
''' [cnurse] 9/7/2004 Created
120
''' [jhenning] 09/06/2005 Utilizing ClientAPI EnableMinMax
121
''' </history>
122
''' -----------------------------------------------------------------------------
123
Public Property IsExpanded()Property IsExpanded() As Boolean
124
Get
125
Return DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxContentVisibile(imgIcon, Not _isExpanded, Utilities.DNNClientAPI.MinMaxPersistanceType.Page)
126
127
End Get
128
Set(ByVal Value As Boolean)
129
_isExpanded = Value
130
DotNetNuke.UI.Utilities.DNNClientAPI.MinMaxContentVisibile(imgIcon, Not _isExpanded, Utilities.DNNClientAPI.MinMaxPersistanceType.Page) = Value
131
End Set
132
End Property
133
134
/**/''' -----------------------------------------------------------------------------
135
''' <summary>
136
''' JavaScript is the name of the javascript function implementation.
137
''' </summary>
138
''' <value>A string representing the name of the javascript function implementation</value>
139
''' <remarks>
140
''' </remarks>
141
''' <history>
142
''' [cnurse] 9/7/2004 Created
143
''' </history>
144
''' -----------------------------------------------------------------------------
145
Public Property JavaScript()Property JavaScript() As String
146
Get
147
Return _javaScript
148
End Get
149
Set(ByVal Value As String)
150
_javaScript = Value
151
End Set
152
End Property
153
154
/**/''' -----------------------------------------------------------------------------
155
''' <summary>
156
''' The MaxImageUrl is the url of the image displayed when the contained panel is
157
''' collapsed.
158
''' </summary>
159
''' <value>A string representing the url of the Max Image</value>
160
''' <remarks>
161
''' </remarks>
162
''' <history>
163
''' [cnurse] 9/7/2004 Created
164
''' </history>
165
''' -----------------------------------------------------------------------------
166
Public Property MaxImageUrl()Property MaxImageUrl() As String
167
Get
168
Return _maxImageUrl
169
End Get
170
Set(ByVal Value As String)
171
_maxImageUrl = Value
172
End Set
173
End Property
174
175
/**/''' -----------------------------------------------------------------------------
176
''' <summary>
177
''' The MinImageUrl is the url of the image displayed when the contained panel is
178
''' expanded.
179
''' </summary>
180
''' <value>A string representing the url of the Min Image</value>
181
''' <remarks>
182
''' </remarks>
183
''' <history>
184
''' [cnurse] 9/7/2004 Created
185
''' </history>
186
''' -----------------------------------------------------------------------------
187
Public Property MinImageUrl()Property MinImageUrl() As String
188
Get
189
Return _minImageUrl
190
End Get
191
Set(ByVal Value As String)
192
_minImageUrl = Value
193
End Set
194
End Property
195
196
/**/''' -----------------------------------------------------------------------------
197
''' <summary>
198
''' The ResourceKey is the key used to identify the Localization Resource for the
199
''' title text.
200
''' </summary>
201
''' <value>A string representing the ResourceKey.</value>
202
''' <remarks>
203
''' </remarks>
204
''' <history>
205
''' [cnurse] 9/7/2004 Created
206
''' </history>
207
''' -----------------------------------------------------------------------------
208
Public Property ResourceKey()Property ResourceKey() As String
209
Get
210
Return _resourceKey
211
End Get
212
Set(ByVal Value As String)
213
_resourceKey = Value
214
End Set
215
End Property
216
217
/**/''' -----------------------------------------------------------------------------
218
''' <summary>
219
''' The Section is the Id of the DHTML object that contains the xection content
220
''' title text.
221
''' </summary>
222
''' <value>A string representing the Section.</value>
223
''' <remarks>
224
''' </remarks>
225
''' <history>
226
''' [cnurse] 9/7/2004 Created
227
''' </history>
228
''' -----------------------------------------------------------------------------
229
Public Property Section()Property Section() As String
230
Get
231
Return _section
232
End Get
233
Set(ByVal Value As String)
234
_section = Value
235
End Set
236
End Property
237
238
/**/''' -----------------------------------------------------------------------------
239
''' <summary>
240
''' The Text is the name or title of the section
241
''' </summary>
242
''' <value>A string representing the Title Text.</value>
243
''' <remarks>
244
''' </remarks>
245
''' <history>
246
''' [cnurse] 9/7/2004 Created
247
''' </history>
248
''' -----------------------------------------------------------------------------
249
Public Property Text()Property Text() As String
250
Get
251
Return lblTitle.Text
252
End Get
253
Set(ByVal Value As String)
254
lblTitle.Text = Value
255
End Set
256
End Property
257
258
#End Region
259
260
Event Handlers#Region "Event Handlers"
261
/**/''' -----------------------------------------------------------------------------
262
''' <summary>
263
''' Assign resource key to label for localization
264
''' </summary>
265
''' <param name="sender"></param>
266
''' <param name="e"></param>
267
''' <remarks>
268
''' </remarks>
269
''' <history>
270
''' [VMasanas] 05/11/2004 Move code to Page_Load for localization
271
''' </history>
272
''' -----------------------------------------------------------------------------
273
Private Sub Page_Load()Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
274
Try
275
'set the resourcekey attribute to the label
276
If ResourceKey <> "" Then
277
lblTitle.Attributes("resourcekey") = ResourceKey
278
End If
279
Catch exc As Exception 'Module failed to load
280
ProcessModuleLoadException(Me, exc)
281
End Try
282
283
End Sub
284
285
286
/**/''' -----------------------------------------------------------------------------
287
''' <summary>
288
''' Renders the SectionHeadControl
289
''' </summary>
290
''' <param name="sender"></param>
291
''' <param name="e"></param>
292
''' <remarks>
293
''' </remarks>
294
''' <history>
295
''' [VMasanas] 04/11/2004 Moved code from Page_Load to PreRender so all other properties are set.
296
''' This allows to inject this control dynamically on a page using LoadControl
297
''' [jhenning] 09/06/2005 Utilizing ClientAPI EnableMinMax
298
''' </history>
299
''' -----------------------------------------------------------------------------
300
Private Sub Page_PreRender()Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
301
Try
302
Dim ctl As HtmlControl = CType(Me.Parent.FindControl(Section), HtmlControl)
303
If Not ctl Is Nothing Then
304
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(imgIcon, ctl, Not IsExpanded, Page.ResolveUrl(MinImageUrl), Page.ResolveUrl(MaxImageUrl), Utilities.DNNClientAPI.MinMaxPersistanceType.Page)
305
End If
306
307
'optionlly show hr
308
pnlRule.Visible = _includeRule
309
310
Catch exc As Exception 'Module failed to load
311
ProcessModuleLoadException(Me, exc)
312
End Try
313
End Sub
314