Wednesday, March 10, 2010
 
 View Article    
19

This is fresh from the forums.asp.net 19th january:

"I've written a tutorial detailing how I created my random image module for DNN 3.x. The tutorial gives step by step details on how you can create the same module using C#

http://www.bitethebullet.co.uk/RandomImageTutorialPart1/tabid/63/Default.aspx

Mark

http://www.bitethebullet.co.uk
Free DotNetNuke Modules"

 

This is Shaun's classic introduction to DNN development on version 4.x:

DotNetNuke Starter kit and templates (by Shaun Walker).

 

Post on forums.asp.net, 19th january by Michael Washington:

"I have been a big supporter of DAL Builder Pro for over a year. When I really looked at what the program did for me, I realized that it was mostly the set-up that it helped me with, because every DotNetNuke module you create has to have pages set-up with the proper names, namespaces, and class names. This could take up to 45 minutes. Of course you would want to use a code generator because it could do it in 5 minutes.

You can now do this for free using the DotNetNuke Website Starter Template.

Once the "shell" is created I usually coded the rest of the module by hand because the automatic code generator could potentially overwrite some of my custom code. The code needed to write to the DotNetNuke Data Access Layer (DAL) is actually very little. With asp.net 2.0 the code needed has further been reduced. I think that a code generator is no longer needed.

For example, In my GuestBook module (download the module and code from: http://adefwebserver.com/dotnetnuke/DotNetNuke/DNN4GuestBook/tabid/199/Default.aspx ),

To add the code to get all the entries from the guestbook (for a particular ModuleID) I would follow these steps:

1) Create the stored Procedure
2) Add a few lines to SqlDataProvider.vb
3) Add a few lines to DataProvider.vb
4) Create a simple class file to hold my data GuestBookInfo.vb
5) Add a few lines to my "Controller" GuestBookController.vb
6) Bind the "Controller" to a web control or call the method in my code.

I do not consider this to be a big deal because:

1) The Add a few lines is really only 3-4 lines of code that is usually copied from an existing method with just a few changes made (for example to specify the name of the stored procedure to call). It takes seconds to do this. Far faster than it would to configure the code generator.

2) The code generator can save me time by creating the class file to hold the data (GuestBookInfo.vb). However I should be used to creating these class files in my normal programming procedure. I should be able to create a 10 property class file with private members and public accessors in 10 minutes. Using a code generator would save me only a few minutes.

3) The rest of the code is code I would normally need. There is nothing special about DotNetNuke. It can be argued that only steps 2-3 are DotNetNuke specific (because they support the database agnostic design of the DAL).

From my experience the issue is that a lot of programmers find the DAL hard to understand. Few resources exist that explain in simply. This is further compounded by that fact that with Visual Studio 2003 the development set-up was extremely complex.

That is no longer the case. The Visual Studio 2005 set-up is extremely simple. Once they understand that the DataProvider.vb contains methods that are overridden by methods in the SqlDataProvider.vb and that the SqlDataProvider.vb contains the methods that call the stored procedures they are able to grasp it.

This leaves the methods in the "...Controller.vb" file that may seem new:

Public Shared Function GuestBook_GetAll(ByVal ModuleId As Integer) As List(Of GuestBookInfo)
Return CBO.FillCollection(Of GuestBookInfo)(DataProvider.Instance().YourCompany_GuestBook_GetAll(ModuleId))
End Function

1) CBO.FillCollection - is a DotNetNuke Function (It is code that is part of the Core). It Hydrates your Custom Class with data returned from your data source. This is for filling a collection (multiple rows of data. There is also a "CBO.FillObject" for Hydrating a single object). What does this mean in English? Basically you have data that was returned from your data source. You want to put this data in the object (class) that you created ("GuestBookInfo" in GuestBookInfo.vb). This is the function that will do it.

2) DataProvider.Instance() - This is where the magic happens. This is the code that reads the web.config file to see what the current configured data source is and connects to it. If you're using SQL server it would be the code in the SqlDataProvider.vb file. If you were using Oracle it would probably be code in a "OracleDataProvider.vb" file.

3) The YourCompany_GuestBook_GetAll(ModuleId) is the method in the DataProvider.vb that is overridden by the method in SqlDataProvider.vb that connects to the stored procedure.

Essentially that's it!

I am working on a complete explanation in my tutorial at:

http://www.adefwebserver.com/DotNetNukeHELP/DNN_Module4/"

This tutorial was finished on a 22th january and is a great resource.

Great info. Michael, thanks a lot!

 

If you have not moved to Version 4.x yet then the ATGen SDK from AppTheory is a codegenerator integrated with MyGeneration and tailored to make DNN modules:

http://projects.apptheory.com/ATGenSDK/tabid/187/Default.aspx

 

The training videos at traincert.net are still valid for teaching you the DNN framework and how to develop against it.

The setup will be different though on DNN4 with the Starter kit, and a lot less code to write.

The good thing about the TrainCert videos is that they "force" you to write the code by hand (so you remember easier). I am here talking about the series of videos you can buy a subscription for at www.traincert.net (includes some ASP.Net 2.0 stuff too).

Some free videos from TrainCert and Seabury Designs are available from dotnetnuke.com.

When searching for something DNN related try the DNNBot search engine, I often find things quicker that way than with Google.

Posted in: Developing

Post Rating

Copyright 2008 by FaktNet Terms Of Use Privacy Statement