Browse DevX
Sign up for e-mail newsletters from DevX


Build 'Radioactive' Web Sites with DotNetNuke 2.0 : Page 6

Save hours of valuable development time when building corporate or departmental Web portals with DotNetNuke 2.0, the latest version of the free, ASP.NET-based, open source, extensible, content management portal.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Step 3: Construct the Presentation Layer
With the Data Store layer and Data Access layer implementation complete, let's create the Presentation layer portion of the module. The user interface will consist of two pieces. The initially displayed piece will list all the individual exam results and the second piece will provide a place to edit existing records or add new exam results.

  1. Right-click on the ExamTracker project, select Add, select Add New Item..., select Web User Control, and name the new file viewExamTracker.
  2. Use Listing 6 as a reference for the viewExamTracker.ascx file. It contains a datagrid that lists the existing records from the ExamTracker table.
  3. Use Listing 7 as a reference for the viewExamTracker.ascx.vb file. The first thing of interest is that the viewExamTracker class is inherited from the DotNetNuke.PortalModuleControl.
The DotNetNuke.PortalModuleControl class contains properties and methods required by DNN to inject custom modules into a page. The ModuleID is a significant property. It tracks the ModuleID of the current module. To keep things simple I choose not to use this feature here. You can create modules so that you can use them on multiple tabs. Many of the included modules take advantage of this design feature. For example, you can add the Announcements module on multiple tabs across a site and each Announcement module retains its information independently of the others. I could have implemented this in the ExamTracker module by adding a ModuleID field to the ExamTracker table, modifying the stored procedures to accept and return the ModuleID, and modifying the data access methods to accept a ModuleID parameter. I will leave implementing that to you as an experiment once you get the module working.

The MyBase.Actions.Add call in the Page_Init is the first item of interest in this file.

' declare module actions MyBase.Actions.Add(GetNextActionID, "Add New Exam", _ "", URL:=EditURL(), _ secure:=SecurityAccessLevel.Edit, _ Visible:=True)

This snippet adds the option to add a new exam when the user selects the menu next to the module title. Add additional lines here for additional options.

The Page_Load method contains the code that retrieves the existing ExamTracker records and binds them to the DataGrid.

  1. Next is the piece that will handle editing or adding records. Right-click on the ExamTracker project, select Add, select Add New Item..., select Web User Control, and name the new file editExamTracker.
  2. Use Listing 8 as a reference for the editExamTracker.ascx file. It contains controls to display the fields and buttons to update, cancel, or delete the current record.
  3. Use Listing 9 as a reference for the editExamTracker.ascx.vb file. It contains all the code necessary to assign values to the controls as well as options for updating, canceling, or deleting the current record.
  4. Try to build the project at this point. You should be able to build with no errors.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date