The general controls in DNN are mainly used in DotNetNuke. in the UI namespace, all modules closely related to module development are in DotNetNuke. UI. in UserControls, they are indispensable elements for developing DNN-style modules.
LabelControl
Introduction:
Label control. This should be the most commonly used control. It serves as a prompt in front of the input box. If you click the question mark icon, you can give a detailed description.
Location:
Controls \ LabelControl. ascx
Attribute:
ControlName: control. Specifies the control that the label applies. If you click a tag, the corresponding focus can be obtained.
Text: the label displays Text.
HelpKey: The ResourceKey corresponding to the tag help (obtain the corresponding keyword in the language resource file)
HelpText: help text of tags. If HelpText = "" is displayed during use, the question mark icon before the label is not displayed.
ResourceKey: obtain the corresponding keyword in the language resource file. In fact, we only need to set a ResourceKey and use ResourceKey. Text and ResourceKey. Help in the resource file to represent the tag Text and Help Text respectively. This attribute can also be used in other ASP. NET controls. DNN automatically analyzes this attribute and uses it as the Text value. For example, Lable, Button, HyperLink, and ListItem (in RadioButtonList and DropDownList, you can specify the ResourceKey attribute in the ListItem to implement multi-language functions ), you can find a large number of examples in the built-in DNN module.
Suffix: The Suffix of the text displayed after the tag. For example :? Or:
Usage:
1. register the control on the page to be applied, for example:
<% @ Register TagPrefix = "dnn" TagName = "Label" Src = "~ /Controls/LabelControl. ascx "%>
2. Write the following code as needed, for example:
<Dnn: label id = "plTitle" runat = "server" controlname = "txtTitle" suffix = ":"/>
DualListControl
Introduction:
It is a double list box Selection control. It is applicable to selecting a desired content within a specified range. It can be used in the DotNetNuke program and is easy to use. You only need to set the corresponding attributes. For example, to implement an authorization function, you can read all the roles in the system from the Available list and move the roles to be authorized to the Assigned list.
Location:
Controls \ DualListControl. ascx
Attribute:
ListBoxWidth: String type, ListBox width
ListBoxHeight: String type, ListBox width
Available: ArrayList type, Available content
Assigned: Type: ArrayList, selected content
DataTextField: String type, text field of the list box
DataValueField: String type, Value Field of the list box
Enabled: Boolean type, valid or not
Usage:
1. register the control on the page to be applied, for example:
<% @ Register TagPrefix = "Portal" TagName = "DualList" Src = "~ /Controls/DualListControl. ascx "%>
2. Write the following code as needed, for example:
<Portal: duallist id = "ctlAdminRoles" runat = "server" ListBoxWidth = "130" ListBoxHeight = "130" DataValueField = "RoleName" DataTextField = "RoleName"> </portal: duallist>
3. Declare the control in the background code
Protected WithEvents ctlAdminRoles As DotNetNuke. UI. UserControls. DualListControl
4. Bind The ArrayList of Available and Assigned in the background code, for example:
Dim objRoles As New RoleController
Dim arrSysRoles As New ArrayList
'Get all roles of the current site
ArrSysRoles = objRoles. GetPortalRoles (PortalId)
Dim arrAvailableAdminRoles As New ArrayList
Dim arrAssignedAdminRoles As New ArrayList
ArrAvailableAdminRoles = arrSysRoles
'When the role is not created, the ArrayList of the selected role is initialized, and the selected part is sent to the ArrayList of the selected role.
'Objinfo. AdminRoles is a semicolon-separated role name.
'Ctladminroles: DualListControl
If Not objInfo Is Nothing Then
'Obtain the selected role
Dim arrAdminRoles As String () = objInfo. AdminRoles. Split (";")
Dim RoleName As String
For Each RoleName In arrAdminRoles
Dim objRole As New RoleInfo
ObjRole. RoleName = RoleName
ArrAssignedAdminRoles. Add (objRole)
Next
For Each objAvailableRole As RoleInfo In arrAvailableAdminRoles
For Each objAssignedRole As RoleInfo In arrAssignedAdminRoles
If objAvailableRole. RoleName = objAssignedRole. RoleName Then
ArrAvailableAdminRoles. Remove (objAvailableRole)
End If
Next
Next
End If
CtlAdminRoles. Available = arrAvailableAdminRoles
CtlAdminRoles. Assigned = arrAssignedAdminRoles
CtlAdminRoles. DataBind ()
5. Obtain the selected items from the control.
'Stradminroles: Role names separated by semicolons
'Ctladminroles: DualListControl
Dim strAdminRoles As String = String. Empty
For Each objItem As ListItem In ctlAdminRoles. Assigned
StrAdminRoles = strAdminRoles + ";" + objItem. Text
Next
StrAdminRoles = strAdminRoles. Substring (1)
ModuleAuditControl
Introduction:Controls that display the creator and creation time.
Location:Controls \ ModuleAuditControl. ascx
Attribute:
CreatedByUser: the creator. In DNN3.3.x, you can directly enter the user ID to display the user name.
CreatedDate: Creation Time.
Usage:
1. register the control on the page to be applied, for example:
<% @ Register TagPrefix = "Portal" TagName = "Audit" Src = "~ /Controls/ModuleAuditControl. ascx "%>
2. Write the following code as needed, for example:
<Portal: Audit id = "ctlAudit" runat = "server"/>
3. Declare and use the control in the background code
Protected WithEvents ctlAudit As ModuleAuditControl
CtlAudit. CreatedDate = objArticle. CreatedDate. ToString
CtlAudit. CreatedByUser = objArticle. CreatedByUser. ToString
SectionHeadControl
Introduction:
You can select to group some widgets displayed in a table. Use this control to hide and expand this control group. DNN is used in many page settings and host settings. If the module you develop has a lot of fields to be input, you may also use this control to group the information you want to enter and hide some less used fields to simplify the interface.
Location:
Controls \ SectionHeadControl. ascx
Attribute:
CssClass: Style
IncludeRule: whether to display a horizontal line IsExpanded: Indicates whether to expand the control.
JavaScript: Specify the JavaScript function used to expand and collapse the function. You do not need to set the default value first.
MaxImageUrl: the icon address is displayed when it is expanded. By default.
MinImageUrl: the icon address displayed during collapse. By default.
ResourceKey: obtain the corresponding keyword in the language resource file.
Text: select the label Text. You can specify the ResourceKey and provide the corresponding value in the resource file.
Section: ID of the control to be expanded and collapsed, which is generally table or div. To use this function, the tables and div must be runat = "server ".
Usage:
1. register the control on the page to be applied, for example:
<% @ Register TagPrefix = "dnn" TagName = "SectionHead" Src = "~ /Controls/SectionHeadControl. ascx "%>
2. Write the following code as needed, for example:
<Dnn: sectionhead id = "dshAuthorize" cssclass = "Head" runat = "server" isexpanded = "False" text = "Authorize Settings"
Section = "tblAuthorize" resourcekey = "dshAuthorize"/>
<Table id = "tblAuthorize" runat = "server"> <tr> <td> content to be folded or expanded </td> </tr> </table>
As this article has long been written, there are three controls, TextEditor, UrlControl, and URLTrackingControl. The contents of this article are also divided into the DNN module development series (6) -- general controls in DNN (below.
Series Article Navigation:
DNN module development series (1) -- Analysis and Design
DNN module development series (2) -- Build a module development project
DNN module development series (3) -- add module definitions in DNN
DNN module development series (4)-classes related to module development
DNN module development series (5) -- General controls in DNN (I)