When I was about to launch my web application, I found myself in front of a daunting task of creating support pages for the website. It is difficult for solo acts like me to think about content for Privacy policy, Terms of Use, Copyright as well as support facilities like forums, feedback, faq and even plain and simple help pages. I’m no web designer too. Dotnetnuke has allowed me to do all these and in less than a day I was able to get it up and running with most of the support pages in place. Having have to worry only about content, in a few more days, the rest of the pages are there too.
Now, what about my pre-existing web pages? I need to convert them to Dotnetnuke modules. Looking around there were very limited resources on the internet on how to go about this. Even forums don’t contain that much information. I’ve downloaded documents for Dotnetnuke Module Development but they were more geared toward re-distributing these modules. Thus too complicated and time consuming for my needs. I might as well create the support pages myself in plain html or .aspx. I just need a quick and simple way to convert my web forms to Dotnetnuke modules.
After a substantial time of tinkering, I was finally able to do it and narrow down DNN Module Development to 10 easy steps. I’m putting it here so that those of you on the same predicament might have use for it and spare yourself the wasted hours trying to figure it out.
To begin,
1. Locate the DesktopModules Folder under you DNN website.
2. Create a under folder it and name it HelloWorld.
3. Right-click the said folder and click Add New Item
4. Select Web User Control and Name it HelloWorldModule.ascx
5. Replace class declaration to inherit from DotNetNuke.Entities.Modules.PortalModuleBase instead of System.Web.UI.UserControl
6. Import the namespaces DotNetNuke and DotNetNuke.Entities.Modules
7. Now let’s do something simple, drag and drop a Label control in the design view of your User Control.
8. On your code behind, create a page load event and add Label1.text = “Hello World!”
You user control’s html should now look like this.
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="HelloWorldModule.ascx.vb" Inherits="DesktopModules_DNNSchool_HelloWorldModule" %>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
And your code-behind class like this
Imports DotNetNuke
Imports DotNetNuke.Entities.Modules
Partial Class DesktopModules_DNNSchool_HelloWorldModule
Inherits DotNetNuke.Entities.Modules.PortalModuleBase
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Label1.Text = "Hello World!"
End Sub
End Class
9. Login to your DNN website and go to Host > Module Definitions. Locate “Import Module Definition” link and click
10. From Control dropdown, locate DesktopModules/HelloWorld/HelloWorldModule.ascx and click Import Control
Your first Dotnetnuke Module is now available in the Module dropdown in the Control Panel. Congratulations!
Go ahead and to a page. You’ll see your new Dotnetnuke module declaring it’s existence to the world.
Just repeat steps 2-7 if you want to create more Modules. Probably step 1 too if your want a “cooler” folder name. Then just code as you would any other Web User Control or a Web form for that matter in Visual Studio.
0 comments:
Post a Comment