AspAlliance.com LogoASPAlliance: Articles, reviews, and samples for .NET Developers
URL:
http://aspalliance.com/articleViewer.aspx?aId=107&pId=-1
ASP Migration to ASP.NET
page
by . .
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 27052/ 46

Introduction

ASP Migration to ASP.NET

Published on 09/07/01

 

Nobody expects the Spanish Inquisition

ASP.NET is not light work, I've been reading two books at the same time, one on ASP 3 and the other on ASP.NET and its like learning two different languages (VBScript and VB.NET) and I found that treating them as different makes it easy to learn the language (from now on when I refer to language it mean VB.NET being use in ASP.NET) and adapt it to my old applications. This article will not touch all the changes (the changes from Beta 1 to Beta 2 are many many many pages alone) but I want to give you a look at what to expect.

The one thing I hate

I have read multiply books on ASP and I am very very pissed off about the following statement being used -

Response.Write "Hi"

Do you see it? When calling a method ALWAYS use brackets for the parameters. I always have and its very good practice and makes code more readable, ASP.NET has finally put a stop the madness of this by forcing people to use -

Response.Write("Hi")

And its about time too.

This isn't VBScript

Its VB not VBScript

VB.NET isn't the next version of VBScript (that's out the window), its VB, that means that you can take a VB.NET application and plonk it into an ASP.NET page with minor problems. It also allows more functionality in the script and use of some more advanced functionality

Class Animal
private species as string
private id as integer

Sub change_stuff(a as string, optional b as integer = 0)
If Len(id) Then id = b
species = a
End Sub


End Class

I don't think I've ever seen a class in ASP, or the keywords - public and private used. This opens up much more space for people to create custom types without the use of an object. The optional keyword is also something new. I once read an ASP tutorial where the author wrote all the code in VB and then told us how to change it to ASP, that was not only terrible but I first saw the optional keyword and thought that it would be great, its like in C++. Now we can specify optional parameters (with default values) and use them. I can then do the following.

Dim wolf as New Animal
Dim panda as New Animal

wolf.change_stuff("Canis rufus", 2)
panda.change_stuff("Ailuropoda melanoleuca
")

This gives makes wolf.species = "Canis rufus" wold.id = 2 and panda.species = "Ailuropoda melanoleuca" panda.id = 0. Also check out the New keyword being used. This replaces the set keyword in ASP. Instead of -

Set objConn = Server.CreateObject("ADODB.Connection")

We use -

Dim objConn as new OleDBConnection([Connection String and other parameters])

Basically nearly all of VB.NET's functionality rubs off on ASP.NET as well, there may be a few things such as forms to deal with.

There are also many more things of VB.NET that is very useful in ASP.NET such as the try...catch...finally statement. This allows you to try to perform a task, catch any errors and handle them. I will discuss this in more detail in my exception's in ASP.NET article.

Web Forms

Web Forms

You've probably heard of these if you've done research into ASP.NET, they are a bit complicated at first and I think I'm getting OOS (or RSI) from writing runat=server constantly. But they do provide a lot of new features (see my DataGrid's in ASP.NET), although a DataGrid isn't in a form tag its still one of those new GUI things that are built in. VB6 people will remember DataGrids and these are very similar. It allows dynamic things to happen with your form elements. The new GUI controls (well they produce GUI elements like tables) are much better that conventional ways, see my BDP article for the table and then the DataGrid's in ASP.NET article and check out the difference. I won't go into it too much, but I'll give you an example -

<form runat=server>

<asp:textbox id="name" ontextchanged="name_change()" runat=server />

<asp:button id="submit" runat=server />

</form>

This creates a textbox and a button that were generated on the server, they ontextchanged property allows me to execute server-side functions or events like with the client-side version, but this time it can perform more advanced things. The ontextchanged happens when we submit the form, the action by default it to post back to the page and any events are handled on the page. ( name_change() is a method on the page).

ADO.NET

ADO.NET

ADO.NET is the next version of ADO, there isn't much difference, but there is a huge lean towards SQL Server. There are new ADO objects, connectors, commands, adaptors, etc. and there is an exact duplicate for the SQL Server versions, the SQL Server versions are said to provide more functionality for SQL Server and let it open up its features with XML and all that, I think its just bias to their only database server. There is also a lot of stuff to do with data storage and greater support in VS.NET for these new tools. They can make the access a bit longer, as filling a dataset requires a data adapter, a data connection and usually a data command.

Web Services

Web Services

Web services may be a replacement to components, then again, maybe not. Web Services are very similar to components, you create functions and classes and other stuff in VB/C#/Any .NET language and then you just make the things that you want available to the web. MSDN's .NET show has a show where they create a web service and make it available to people, its very good if you are new to .NET available at - http://msdn.microsoft.com/theshow/Episode013/default.asp, I actually learnt a lot from just watching this episode.

A web service basically gets information and then churns out something (not always) in XML, this data could be a dataset or a string manipulation event may occur. Components however are a bit different as they are a whole application in one, web services I don't see as being an application as much an information provider. Components however are being taken over by these new web services, although I don't like it, it may be wise to think about how to do your old stuff in the new web service way. I plan to do an article on web services, but its quite hard to explain.

Additional Reading

Where now?

Here we have only scratched the surface of ASP.NET, the whole .NET platform is huge and Microsoft has provided a wealth of information on it, I like to use the .NET show best because I respond best to a visual approach. Here are some episodes that I like :

  1. http://msdn.microsoft.com/theshow/Episode013/default.asp - Creating a simple .NET subscription service using ASP.NET and web services.
  2. http://msdn.microsoft.com/theshow/Episode009/default.asp - ASP.NET, what it is and changes from ASP 3
  3. http://msdn.microsoft.com/theshow/Episode011/default.asp - .NET, what is .NET
  4. http://msdn.microsoft.com/theshow/Archive.asp - Archives of the show, the most recent ones have information on VB.NET and VS.NET\

I hope that I have given you some more insight into ASP.NET and what changes it will involve for developers. A great option is to get a book on .NET (see related articles), or a book specifically on ASP.NET (see upcoming articles). I hope that I have left you with some information that will be worthwhile to you in what will come.

 


Product Spotlight
Product Spotlight 

©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-03-29 7:40:39 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search