Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

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.

IsInstalled

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)

DotNetNuke.Framework.AJAX.IsInstalled

RegisterScriptManager()

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
    DotNetNuke.Framework.AJAX.RegisterScriptManager()
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
                ShowData(1)
            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"))
                    colDesktopModules.Add(objDesktopModules)
                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
            Else
                btnPrevious.Visible = True
            End If
            If pagedData.IsLastPage Then
                btnNext.Visible = False
            Else
                btnNext.Visible = True
            End If
 
            Me.GridView1.DataSource = pagedData
            Me.GridView1.DataBind()
 
        End Sub
 
        Protected Sub Next_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            CurrentPageIndex = Convert.ToInt32(Me.lblCurrentPage.Text) + 1
            ShowData(CurrentPageIndex)
        End Sub
 
        Protected Sub btnPrevious_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            CurrentPageIndex = Convert.ToInt32(Me.lblCurrentPage.Text) - 1
            ShowData(CurrentPageIndex)
        End Sub
    End Class
 
    Public Class myDesktopModules
        Dim _FriendlyName As String
        Dim _Description As String
        Public Property FriendlyName() As String
            Get
                Return _FriendlyName
            End Get
            Set(ByVal value As String)
                _FriendlyName = value
            End Set
        End Property
        Public Property Description() As String
            Get
                Return _Description
            End Get
            Set(ByVal value As String)
                _Description = value
            End Set
        End Property
    End Class
End Namespace

Comments

Comment Form

Only registered users may post comments.

NewsArchives


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Daniels (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
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 (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (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)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out