Objects and Object oriented programming have been around for a long time in mainstream desktop and client/server programming (since 1967 in fact.) Traditionally, web development has been dominated by procedural based scripting languages. It is only recently that OOP has begun to integrate into the web-programming world. Languages used to create dynamic websites such as Java, Perl, PHP and Coldfusion have begun to implement object-orientation into their feature sets or improve on the OOP features they already had. In ASP 3, objects could be manipulated or created through COM and VBScript. However, in ASP.NET, Microsoft has brought ASP to a new level of "object-orientedness" not previously seen in web programming languages.
Perhaps you’ve been using ASP.NET for a while and you’re not sure if you’re doing everything right when it comes to this OOP stuff. Or perhaps you are still writing ASP.NET code primarily in a script fashion similar to ASP 3. With these two articles, Craig Bowes will discuss how to use OOP features in your ASP.NET web applications.
Requirements To do the examples in this article, you’ll need the following software:
The .NET framework
The .NET SDK to compile your applications
Visual Studio .NET, Web Matrix or your favorite text editor.
You should also be somewhat familiar with at web programming in one language, preferably VB 6 or VBScript. I’ll show code related to this article in VB.NET, but also have the examples downloadable in C# as well. You should also already know how to compile files using the SDK or VS.NET.
Target Audience Chances are you are probably familiar with objects and object-oriented programming. In fact, this article assumes that you know enough to be able to compile a VB or C# file and use the basic event handling features in ASP.NET such as the Page_Load event handler. A complete study of OOP would be a topic that could easily fill many volumes and there are many articles, books and websites devoted to OO theory. Such a study is outside the scope of this article. However knowing what OOP is and does is different than knowing how use it in code. In this article, we’re going to look at the basic OOP features in the .NET framework and laying the ground work for using things like classes, constructors, methods, fields and properties in ASP.NET. In Part II, we’ll look at more advanced features and architecture in OOP. This will include inheritance, polymorphism, aggregates and interfaces.
Perhaps you’ve been using ASP.NET for a while and you’re not sure if you’re doing everything right when it comes to this OOP stuff. Or perhaps you are still writing ASP.NET code primarily in a script fashion similar to ASP 3. If you are already a strong "object architect" that has used object-oriented features such as aggregation, polymorphism and inheritance for years, then this article will probably seem a bit basic for you. Hard-core Java and C++ programmers will probably fall into this category. However, if you’ve been writing mostly procedural or non-OOP code in your classic ASP web applications using VBScript, then this article may help you get a handle on writing OOP style code with ASP.NET’s new features.