Sections
spotlight
     
     
WWWCoder.com Resource Directory

Use Base Pages In Your Applications
2/15/2006 10:05:26 AM

In this article we'll discuss the use of base pages within an application. One application that most notably uses base pages is DotNetNuke. We'll look this over and see what benefits it can bring your applications.

Class PageBase

Using DotNetNuke as an example for this tutorial you can see there is a class called PageBase located in the Shared folder (PageBase.vb). Within this class you can see that the PageBase class inherits from the standard System.Web.UI.Page class within the .NET framework.

Public MustInherit Class PageBase
    Inherits System.Web.UI.Page

 

Investigate this class further and you'll see it is broken up into various regions containing public properties, public methods, and corresponding private methods and properties. Let's look at one specific method SetLanguage:

       Public Sub SetLanguage(ByVal value As String)
            ' save the pageculture as a cookie
            Dim cookie As System.Web.HttpCookie = Nothing
            Try
                cookie = Response.Cookies.Get("language")
            Catch
                ' Response is not available in this context
            End Try
            If (cookie Is Nothing) Then
                If value <> "" Then
                    cookie = New System.Web.HttpCookie("language", value)
                    Response.Cookies.Add(cookie)
                End If
            Else
                cookie.Value = value
                Response.Cookies.Set(cookie)
                If value = "" Then
                    Response.Cookies.Remove("language")
                End If
            End If
        End Sub

The SetLanguage method of DNN checks for the language of the pages and manages the cookie settings for the current language.

Okay, so big deal we have a class called PageBase that has methods like language management, security checking, control management, and some other things. How is this going to benefit you as a developer? Let's look at any one of the pages within DNN to see what it's doing with this PageBase class, for example the RSS module (RSS.aspx.vb file):

    Partial  Class RSS
        Inherits Framework.PageBase

You see what it's inheriting? So not only does the page get all the great features provided by the framework via the PageBase since it inherits from the  System.Web.UI.Page it also now gets all the custom methods, and properties that DNN provides within the PageBase class. This enables all the aspx files within the application to have one centralized code base for shared methods like security handling, language, and layout features. Rather than updating each page individually, you now centralize all the code within a single base page class.

 

 


Page Options:
format for printing  Format for Printer
email article  Email Page
add to your favorites   Add to Favorites
How would you rate the quality of this content?
Poor - - Excellent
Comments?
Overall Rating:
Comments Left:
Left on 9/6/2007 4:39:01 AM by Anonymous
Comments:
     
     

 

     
     

 


 


Digg This
 


DotNetNuke Platinum Benefactor

     
     

Other family network sites: santry.com - katieandkarleigh.com

Powered by 

 

     
Copyright 20010 - Santry Technology Solutions, Box 172, Girard, PA 16417, (814) 774-0970
Privacy Statement | Terms Of Use