Learn More





DNN Community Blog

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.

DotNetNuke 4.5 Features: Creating A DotNetNuke Module using ASP.NET AJAX - *Updated*

The DotNetNuke Framework cannot assume that the web server it is running on has ASP.NET AJAX installed. In order to handle this a new class was created in DotNetNuke.Framework.AJAX which provides methods that developers can use to leverage AJAX in their solutions.


Setting Dependencies

One option in developing a DotNetNuke ASP.NET AJAX module is indicating the System.Web.UI.ScriptManager dependency in the module configuration setting:

Modules can optionally specify a semi-colon delimited list of Dependencies which their module requires (for example, indicate System.Web.UI.ScriptManager when your module requires that the site have ASP.NET AJAX installed and enabled). Then, during the installation of the module, if the environment does not support a specific permission, a message will be displayed to the user and the module will not be installed.

IsInstalled and RegisterScriptManager()

If you want to use ASP.NET AJAX functionality only when it is available, you can decide not to use the Dependency and use the IsInstalled flag and the IsEnabled setting.

The IsInstalled flag indicates whether AJAX is available in the environment and the IsEnabled setting must be used by developers to tell DotNetNuke that their module/skin is using AJAX on the page.


The IsInstalled flag is simple to use and can be checked before any ASP.NET AJAX functionality is called. The function returns a Boolean value (true or false)



AJAX needs to be registered very early in the page life cycle for it to be recognized, so DNN inserts the ScriptManager into the page dynamically. If modules loaded on the page use the RegisterScriptManager() method, DNN knows that the page requires AJAX. If no modules use RegisterScriptManager(), then DNN thinks that the page does not require AJAX - and at the Render stage it will REMOVE the ScriptManager from the page (since it thinks it is not necessary and does not need the extra overhead associated).

If DotNetNuke.Framework.AJAX.IsInstalled Then
End If

Supports Partial Rendering

The easiest way to deploy ASP.NET AJAX with DotNetNuke is to enable the Supports Partial Rendering flag in the definition for the module control (Host Menu > Module Definitions > Edit Module Definition > Edit Module Control).

Using this setting you only have to check DotNetNuke.Framework.AJAX.IsInstalled() if you have specific ASP.NET AJAX functionality that you will need to disable if ASP.NET AJAX is not available (see Creating Secure DotNetNuke ASP.NET AJAX Web Services for an example of when this is needed).

By default the Supports Partial Rendering flag is False for all controls. Only if the developer of the module explicitly sets the Supports Partial Rendering flag to True in their *.dnn installation manifest, or the Portal administrator checks the Supports Partial Rendering box, will it be wrapped by an Update Panel (and only if AJAX is installed ).

This functionality provides the simplest, most effective way for a module developer to create an application which works in the lowest common denominator environment - but is also able to take advantage of partial rendering when it is available.

The availability of this feature means that a module developer should seldom ever need to check DotNetNuke.Framework.AJAX.IsInstalled()  or include an Update Panel in their module controls. Instead, the module developer only needs to set the Supports Partial Rendering flag in situations where it makes sense

However, if a control already contains JavaScript for dynamic behaviors, wrapping the control in an Update Panel has the potential to break the control's functionality.

Sample ASP.NET AJAX Application

The sample demonstrates ASP.NET AJAX support. All that was done was to enable the Supports Partial Rendering flag in the user control for the module.

The AJAX sample code can be downloaded at this link. (it will only work with DotNetNuke 4.5.0 or higher)

Imports DotNetNuke
Imports System.Collections.Generic
Namespace DotNetNuke.Modules
    Partial Class Ajax
        Inherits Entities.Modules.PortalModuleBase
        Dim CurrentPageIndex As Integer
        Protected Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            If Not Page.IsPostBack Then
            End If
        End Sub
        Private Sub ShowData(ByVal intCurrentPageIndex As Integer)
            Dim mySqlString As New StringBuilder()
            mySqlString.Append("SELECT FriendlyName, Description ")
            mySqlString.Append("FROM {databaseOwner}{objectQualifier}DesktopModules ")
            mySqlString.Append("ORDER BY FriendlyName")
            Dim colDesktopModules As New List(Of myDesktopModules)
            Using dr As IDataReader = _
                  CType(DataProvider.Instance().ExecuteSQL(mySqlString.ToString(), Nothing), IDataReader)
                While dr.Read
                    Dim objDesktopModules As New myDesktopModules()
                    objDesktopModules.FriendlyName = Convert.ToString(dr("FriendlyName"))
                    objDesktopModules.Description = Convert.ToString(dr("Description"))
                End While
            End Using
            Dim pagedData As New PagedDataSource()
            pagedData.DataSource = colDesktopModules
            pagedData.AllowPaging = True
            pagedData.PageSize = 10
            pagedData.CurrentPageIndex = intCurrentPageIndex - 1
            Me.lblTotalPages.Text = Convert.ToString(pagedData.PageCount)
            Me.lblCurrentPage.Text = Convert.ToString(pagedData.CurrentPageIndex + 1)
            If pagedData.IsFirstPage Then
                btnPrevious.Visible = False
                btnPrevious.Visible = True
            End If
            If pagedData.IsLastPage Then
                btnNext.Visible = False
                btnNext.Visible = True
            End If
            Me.GridView1.DataSource = pagedData
        End Sub
        Protected Sub Next_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            CurrentPageIndex = Convert.ToInt32(Me.lblCurrentPage.Text) + 1
        End Sub
        Protected Sub btnPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            CurrentPageIndex = Convert.ToInt32(Me.lblCurrentPage.Text) - 1
        End Sub
    End Class
    Public Class myDesktopModules
        Dim _FriendlyName As String
        Dim _Description As String
        Public Property FriendlyName() As String
                Return _FriendlyName
            End Get
            Set(ByVal value As String)
                _FriendlyName = value
            End Set
        End Property
        Public Property Description() As String
                Return _Description
            End Get
            Set(ByVal value As String)
                _Description = value
            End Set
        End Property
    End Class
End Namespace


Comment Form

Only registered users may post comments.


2sic Daniel Mettler (124)
Aderson Oliveira (15)
Alec Whittington (11)
Alex Shirley (10)
Andrew Nurse (30)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (21)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (203)
Chris Paterra (55)
Clinton Patterson (28)
Cuong Dang (21)
Daniel Bartholomew (2)
Dave Buckner (2)
David Poindexter (3)
David Rodriguez (2)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (74)
Geoff Barlow (6)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (269)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matthias Schlomann (15)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Mike Horton (19)
Mitchel Sellers (28)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Peter Donker (52)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott S (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Timo Breumelhof (24)
Tony Henrich (3)
Torsten Weggen (2)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (37)
Will Strohl (163)
William Severance (5)
Try Evoq
For Free
Start Free Trial
a Demo
See Evoq Live
Need More Information?