当前文件路径:DNN/Library/Controls/HelpButtonControl.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
Imports DotNetNuke.Entities.Modules
22
23
Namespace DotNetNukeNamespace DotNetNuke.UI.UserControls
24
25
/**/''' -----------------------------------------------------------------------------
26
''' <summary>
27
''' HelpButtonControl is a user control that provides all the server code to display
28
''' field level help button.
29
''' </summary>
30
''' <remarks>
31
''' To implement help, the control uses the ClientAPI interface. In particular
32
''' the javascript function __dnn_Help_OnClick()
33
''' </remarks>
34
''' <history>
35
''' [smehaffie] 12/8/2004 Created
36
''' </history>
37
''' -----------------------------------------------------------------------------
38
Public MustInherit Class HelpButtonControlClass HelpButtonControl
39
Inherits System.Web.UI.UserControl
40
41
Controls#Region "Controls"
42
43
Protected WithEvents cmdHelp As System.Web.UI.WebControls.LinkButton
44
Protected WithEvents imgHelp As System.Web.UI.WebControls.Image
45
Protected WithEvents lblHelp As System.Web.UI.WebControls.Label
46
Protected WithEvents pnlHelp As System.Web.UI.WebControls.Panel
47
48
#End Region
49
50
Private Members#Region "Private Members"
51
52
Private _ControlName As String 'Associated Edit Control for this Label
53
Private _HelpKey As String 'Resource Key for the Help Text
54
Private _ResourceKey As String 'Resource Key for the Label Text
55
56
#End Region
57
58
Public Properties#Region "Public Properties"
59
60
/**/''' -----------------------------------------------------------------------------
61
''' <summary>
62
''' ControlName is the Id of the control that is associated with the label
63
''' </summary>
64
''' <value>A string representing the id of the associated control</value>
65
''' <remarks>
66
''' </remarks>
67
''' <history>
68
''' [cnurse] 9/8/2004 Created
69
''' </history>
70
''' -----------------------------------------------------------------------------
71
Public Property ControlName()Property ControlName() As String
72
Get
73
Return _ControlName
74
End Get
75
Set(ByVal Value As String)
76
_ControlName = Value
77
End Set
78
End Property
79
80
/**/''' -----------------------------------------------------------------------------
81
''' <summary>
82
''' HelpKey is the Resource Key for the Help Text
83
''' </summary>
84
''' <value>A string representing the Resource Key for the Help Text</value>
85
''' <remarks>
86
''' </remarks>
87
''' <history>
88
''' [cnurse] 9/8/2004 Created
89
''' </history>
90
''' -----------------------------------------------------------------------------
91
Public Property HelpKey()Property HelpKey() As String
92
Get
93
Return _HelpKey
94
End Get
95
Set(ByVal Value As String)
96
_HelpKey = Value
97
End Set
98
End Property
99
100
/**/''' -----------------------------------------------------------------------------
101
''' <summary>
102
''' HelpText is value of the Help Text if no ResourceKey is provided
103
''' </summary>
104
''' <value>A string representing the Text</value>
105
''' <remarks>
106
''' </remarks>
107
''' <history>
108
''' [cnurse] 9/8/2004 Created
109
''' </history>
110
''' -----------------------------------------------------------------------------
111
Public Property HelpText()Property HelpText() As String
112
Get
113
Return lblHelp.Text
114
End Get
115
Set(ByVal Value As String)
116
lblHelp.Text = Value
117
imgHelp.AlternateText = HtmlUtils.Clean(Value, False)
118
119
'hide the help icon if the help text is ""
120
If Value = "" Then
121
imgHelp.Visible = False
122
End If
123
End Set
124
End Property
125
126
/**/''' -----------------------------------------------------------------------------
127
''' <summary>
128
''' ResourceKey is the Resource Key for the Help Text
129
''' </summary>
130
''' <value>A string representing the Resource Key for the Label Text</value>
131
''' <remarks>
132
''' </remarks>
133
''' <history>
134
''' [cnurse] 9/8/2004 Created
135
''' </history>
136
''' -----------------------------------------------------------------------------
137
Public Property ResourceKey()Property ResourceKey() As String
138
Get
139
Return _ResourceKey
140
End Get
141
Set(ByVal Value As String)
142
_ResourceKey = Value
143
End Set
144
End Property
145
146
#End Region
147
148
Private Methods#Region "Private Methods"
149
150
/**/''' -----------------------------------------------------------------------------
151
''' <summary>
152
''' GetLocalizedText gets the localized text for the provided key
153
''' </summary>
154
''' <remarks>
155
''' </remarks>
156
''' <param name="key">The resource key</param>
157
''' <param name="ctl">The current control</param>
158
''' <history>
159
''' [cnurse] 9/8/2004 Created
160
''' </history>
161
''' -----------------------------------------------------------------------------
162
Private Function GetLocalizedText()Function GetLocalizedText(ByVal key As String, ByVal ctl As Control) As String
163
'We need to find the parent module
164
Dim parentControl As Control = ctl.Parent
165
Dim localizedText As String
166
167
If TypeOf parentControl Is PortalModuleBase Then
168
'We are at the Module Level so return key
169
'Get Resource File Root from Parents LocalResourceFile Property
170
Dim ctrl As Entities.Modules.PortalModuleBase
171
ctrl = DirectCast(parentControl, PortalModuleBase)
172
localizedText = Services.Localization.Localization.GetString(key, ctrl.LocalResourceFile)
173
ElseIf TypeOf parentControl Is Address Then
174
'We are in an Address Control so return key
175
'Get Resource File Root from Parents LocalResourceFile Property
176
Dim ctrl As Address
177
ctrl = DirectCast(parentControl, Address)
178
localizedText = Services.Localization.Localization.GetString(key, ctrl.LocalResourceFile)
179
Else
180
'Drill up to the next level
181
localizedText = GetLocalizedText(key, parentControl)
182
End If
183
184
Return localizedText
185
End Function
186
187
#End Region
188
189
Event Handlers#Region "Event Handlers"
190
191
/**/''' -----------------------------------------------------------------------------
192
''' <summary>
193
''' Page_Load runs when the control is loaded
194
''' </summary>
195
''' <remarks>
196
''' </remarks>
197
''' <history>
198
''' [cnurse] 9/8/2004 Created
199
''' [jhenning] 9/6/2005 Utilizingnew EnableMinMax function
200
''' </history>
201
''' -----------------------------------------------------------------------------
202
Private Sub Page_Load()Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
203
Try
204
DotNetNuke.UI.Utilities.DNNClientAPI.EnableMinMax(cmdHelp, pnlHelp, True, Utilities.DNNClientAPI.MinMaxPersistanceType.None)
205
206
If _HelpKey = "" Then
207
'Set Help Key to the Resource Key plus ".Help"
208
_HelpKey = _ResourceKey & ".Help"
209
End If
210
Dim helpText As String = GetLocalizedText(_HelpKey, Me)
211
If helpText <> "" Then
212
Me.HelpText = helpText
213
End If
214
215
Catch exc As Exception 'Module failed to load
216
ProcessModuleLoadException(Me, exc)
217
End Try
218
End Sub
219
220
Private Sub cmdHelp_Click()Sub cmdHelp_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdHelp.Click
221
pnlHelp.Visible = True
222
End Sub
223
224
#End Region
225
226
End Class
227
228
End Namespace
229