Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

Rated
Read 66,646 times

Contents

Related Categories

Object-Oriented ASP.NET - Introduction

gregennis

Introduction

ASP.NET brings a whole new world of functionality, power, and ease of rapid development for web programmers. Some of these features, such as the advent of code-behind, are well documented and have become standard practice in everyday development. Another feature ASP.NET brings us is development with a real, compiled language. We can now leverage the object-oriented aspects of these new languages and put them to work in our code. We can take advantage of inheritance, polymorphism, and encapsulation when writing web apps while still maintaining an Microsoft DNA-style n-tier architecture.

I'm not going to try to explain these OO design concepts because they are already the subject of a great many articles (and books). For example, you could try this article on CodeProject for an introduction.

I will be showing a simple example of how you can use inheritance and encapsulation in ASP.NET. I will show how you can customize a datagrid by encapsulating some behavior in a subclass of the datagrid, and thereby making the derived DataGrid class re-usable across multiple forms or applications. I'll be using C# for this example, but the same principles apply to VB.NET.

Comments

  • Getting Error Message when running code

    Posted by ASP_Man on 31 Dec 2003

    I am getting as error message of

    C:\Program Files\ASP.NET Starter Kits\ASP.NET Portal (CSSDK)\PortalCSSDK\RegDataGrid.cs(20): The type or namespace name 'DataSource' could not be found (are y...

  • Posted by ElliotRodriguez on 06 Oct 2003

    Mick:

    shoot me an email at elliotmrodriguezathotmaildotcom and I will send you the class file. Perhaps we can work together on this.

    Oddly enough, when I compile (without errors) and set a refer...

  • Posted by kali_mist on 06 Oct 2003

    Hi Elliot,
    Is there any chance that you can show me the code for the derived datagrid in VB.net.
    Im having trouble creating it myself. Im new to this subclassing stuff.
    Thank you

    Mick Lennon
    Lo...

  • Getting it to work in VB.NET

    Posted by ElliotRodriguez on 03 Oct 2003

    You have to add the class manually as a generic class, then use the Inherits statement

    Public Class DeleteDataGrid ' or whatever you want to call it
    Inherits System.Web.UI.WebControls.DataGri...

  • Great Article

    Posted by ElliotRodriguez on 03 Oct 2003

    great article. I was able to implement the grid in VB.NET quite easily, and I plan on extending it in similar fashion to create DataGrids with selectable rows. Thanks Greg!