This article assumes that you already have an instance of DotNetNuke installed in your development P.C. Please refer to this article for further details:
Disclaimer: This is one method to create a DotNetNuke module. There are of course other approaches that can be taken. I'll be posting links to other related articles very soon.
1. The first step is to create a new Blank Solution. I create these solutions in the C:\DNNDevEnvironment folder- but this solution file can be placed anywhere you wish.
2. Next, add a New Project to the solution.
3. Select ASP.NET Web Application. This tutorial assumes that you have installed DotNetNuke locally to c:\devportals\dnndemo - if you have DNN installed elsewhere, then substitute your path. The project must be created in the DesktopModules folder of your DNN install. Name the project HelloWorldDemo.
4. Delete the Default.aspx and Web.config files (if these are created automatically when you create the project)
5. Add a Web User Control to the project. Name it View.ascx.
6. Right-click on the project and select Properties. On the Application tab, enter an assembly name. The accepted standard is companyname.modules.modulename. For the purposes of this demo, we are using ABCCompany.Modules.HelloWorldDemo.
7. On the Compile tab, enter "..\..\bin" as the build output path.
8. Add a reference to the DotNetNuke.dll file in the bin folder of the DNN installation.
9. Set Copy Local to False and Specific Version to False (this is optional, if you upgrade your development environment to a newer version of DotNetNuke, you won't have to change this reference if you set specific version to False)
10. On the Web tab, set the Project URL to the virtual directory set-up for the DotNetNuke instance. We set this up in the tutorial explaining the installation of DNN on localhost - and we set-up with an alias of DNNDemo.
11. In the View.ascx file, add the code shown below.
12. In the View.ascx.vb file, enter the code shown below. Note that all DNN modules inherit DotNetNuke.Entities.Modules.PortalModuleBase
| Visual Basic |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
Namespace ABCCompany.Modules.HelloWorldDemo
Partial Public Class View
Inherits DotNetNuke.Entities.Modules.PortalModuleBase
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim strName As String = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.DisplayName
Dim strEMail As String = DotNetNuke.Entities.Users.UserController.GetCurrentUserInfo.Membership.Email
Me.Label1.Text = "My name is " + strName + " and my e-mail is: " + strEMail
End Sub
End Class
End Namespace
|
13. Have a look in the bin folder under the root of your local DotNetNuke install. You should see the ABCCompany.Modules.HelloWorldDemo.dll file. (Note: The screenshot below also shows the SqlDataProvider dll - which will be covered in a seperate tutorial)
14. Open your browser and navigate to the localhost insall of DNN. We are using
http://localhost/dnndemo for the purposes of this tutorial. Sign-in as
Host - and select
Host/Module Definitions from the main menu.
15. From the Module Definitions drop-down menu, select Create Module Definition.
16. Enter values as shown below and click Create
17. Next, create a New Definition - name it HelloWorld
18. Next, add the View control. Complete the form as shown below. Note that the Key field is emply and that the source file is the View.ascx file created earlier in this tutorial
19. Navigate to the Home page - now it's time to add our module to a page. Select the Hello World module from the list.
20. Enter Hello World Test as the title and click Add.
21. The module appears on the page.