Moving from Classic ASP to ASP.NET

Soldato
Joined
12 Jan 2004
Posts
6,824
Location
Londinium
Hi guys,

I want to code my next project in ASP.NET rather than classic ASP so I get some experience in .NET. Ive looked at a few books and websites but havent found one that has a good tutorial into getting started with .NET. I alo want to use C# rather than VB as this seems to be becoming the standard. I have a background of Java so it shouldnt be a problem. My trouble is that all of the things I have read make it seem more complicated and difficult than it should be for someone of my experience. Has anyone here been in the same position as me? Do you know a good website that tells you the new way to develop apps in .NET compared to the old method in classic ASP?

Basically, I am confused as to what knowledge from classic ASP can be ported across to .NET - from what Ive seen they look incomparable.

Any help would greatly be appreciated.
 
I've been developing in, amongst others, Asp.Net for nearly 7 years now since it was in Beta, and the only advice I can offer is to NOT think of it as Asp with bells and whistles on.

The backend is VB, so if you're familiar with VB then developing in Asp.Net is quite an easy transition. Whilst I'm not going to enter a war between the benefits of c# over Vb.Net (and vice versa), the transition is definately easier if you know VB.Net. Don't think of the pages as ASP pages, but HTML pages that access a Vb.Net (or c#) program and you should be fine.

The hardest part to understand (or at least when I was learning) is to grasp the understanding that whatever you code in Vb.Net, form control events and methods, aren't handled until the page gets posted back to the server.

So you could have a button on a webform that sends information to a server once it's clicked, but you need to place conditions and checks if a PostBack event is True, and any initialisations to the page if the PostBack event is False.

A perfect mixture of a full Asp.Net system is to stick to traditional methods. Keep all client side handling as JavaScript and all Server or the backend engine to Vb.Net (or c# if you're going down that way) and you shouldn't have any problems at all.

I can't give any example to my work because 99.9% of it is obviously held on clients intranets but you'll be surprised just how windows a web-page feels when it's done properly.

Seriously, it's hard to grasp at first but you can produce some seriously good stuff with it.
 
Whilst I'm not going to enter a war between the benefits of c# over Vb.Net (and vice versa), the transition is definately easier if you know VB.Net.
Ok I won't challange your first statement (I'm a C# fanboy) but I will challange the second. Ok the feature set of vb.net & c# are not exactly the same, but I honestly believe that the syntatic complexity of both languages is about the same. Vb.net just more "wordy" to make up for the lack of extra syntatic charactors (braces {} and the like).

The bigger challange I think is switching between object-orientated and script programming. I have to program in both at work, and I find it takes a couple of hours of programming before I get back upto speed (I'm moving more and more to ASP.NET I'm pleased to say).

akakjs
 
What I'm trying to say is if the OP has come from a back of ASP, then it's far easier for him to migrate into VB.net rather than c# because the vast majority of his ASP based skills will have been using a VB Syntax and not C#.
 
I myself have been coding .NET since it original beta, I think the first thing to get your head around is that it's event driven and not top to bottom as the original asp was. As a good practice try and use the code behind and not embed code into the aspx itself.

As for c# and vb.net, in my opinion its really horses for courses, many people will argue for and against, there is plenty of help available for both and remember this is all about you and as a beginner I would recommend that you make the initial step in vb.net as you already will be familiar with some of the syntax, this should seriously reduce the learning curve that is involved. You can also run c# and vb.net code side by side if you decide to convert across at a later date.

I strongly recommend that before you begin you check out the tutorials at www.asp.net and also get involved with .NET 2005, this will give you a grounding in the controls that are available out of the box and some of the things that are easily achievable. e.g Role based login systems, user profiles and input validation.

One thing to remember, at the moment the default database for .NET is SQL Express, this can cause issues with deployment. I will tell you what u need to know if this is an issue.

If you need to any help at all just ask, I've got access to internal m$ people and i'm actively involved with the coding some of there .NET starter kits.
 
Thanks guys, some really helpful replies there. As for the vb vs c# thing, I simply saw that many organisations were looking for c# skills so I thought I might as well get stuck in with this rather than carrying on with vb.

I just have a few other questions for y'all:

1.) Since the structure of asp and .net are quite different (top down vs event driven), are there any guides for best practices as to how to arrange your code? i.e. should it be script tags at the top that define all your page functions, and beneath that your html content? What about includes in .net, do they work in the same way as in classic? Any structural advice for the pages themselves as well as the app as a whole would be great.

2.) Are there major differences between asp.net 1.0 and 2.0? What is required to run each version, is it just a case of installing the right version of the .net framework?
 
nero120 said:
1.) Since the structure of asp and .net are quite different (top down vs event driven), are there any guides for best practices as to how to arrange your code? i.e. should it be script tags at the top that define all your page functions, and beneath that your html content? What about includes in .net, do they work in the same way as in classic? Any structural advice for the pages themselves as well as the app as a whole would be great.

The code of the page should be done in the code-behind page, each aspx page has the option of having another file behind it, its in this file that code should exist. This allows completely seperation of presentation and code.

nero120 said:
2.) Are there major differences between asp.net 1.0 and 2.0? What is required to run each version, is it just a case of installing the right version of the .net framework?

There are major differences between the new release, and tbh there is no reason of going for anything under version 2, a major one that may interest you is the Version 2 is XHTML out of the box where as prior versions arent. There are plenty of hosts out there that can support you, I personally use hosting in the states as in my humble opinion you get better bang for the buck, just don't go with a budget host.
 
therubble said:
The code of the page should be done in the code-behind page, each aspx page has the option of having another file behind it, its in this file that code should exist. This allows completely seperation of presentation and code.

Okay cool. Is there any way of compiling it without visual web developer installed? Also, are includes no longer used? Are they replaced by using other compiled classes?

There are major differences between the new release, and tbh there is no reason of going for anything under version 2, a major one that may interest you is the Version 2 is XHTML out of the box where as prior versions arent. There are plenty of hosts out there that can support you, I personally use hosting in the states as in my humble opinion you get better bang for the buck, just don't go with a budget host.

I will be using it at work but I dont think they have upgraded to version 2 yet, so its 1.4.11.
 
nero120 said:
Okay cool. Is there any way of compiling it without visual web developer installed? Also, are includes no longer used? Are they replaced by using other compiled classes?

U can just copy the source to the server and it will compile it on the fly, other than that there's also a command line compiler, as for includes look into web user controls.
 
I have another question guys!

I like to use a reasonable amount of JavaScript in my apps (I know, I know!) and I was wondering how Javascript fits into ASP.Net. i.e. can you happily fit ajax type code around asp.net to minimise server calls? From what Ive seen of .nets event driven programming it mostly results in another call to the server increasing traffic (e.g. if a button is clicked). Using Javascript you can handle all gui events locally until you are ready to submit the data to the server, decreasing the total load on the server. Is this approach compatible with asp.net?
 
nero120 said:
I have another question guys!

I like to use a reasonable amount of JavaScript in my apps (I know, I know!) and I was wondering how Javascript fits into ASP.Net. i.e. can you happily fit ajax type code around asp.net to minimise server calls? From what Ive seen of .nets event driven programming it mostly results in another call to the server increasing traffic (e.g. if a button is clicked). Using Javascript you can handle all gui events locally until you are ready to submit the data to the server, decreasing the total load on the server. Is this approach compatible with asp.net?

Javascript is fine, and the framework itself uses it, if your interested in Ajax, take a look at ATLAS, its mentioned on asp.net
 
Thanks Mr Rubble!

Yet one more question for you if I may!

If I wanted to dynamically generate form fields (server controls) on the client side via javascript (say, when the user clicks a button, add a new row of input fields), to be submitted by the user and their values used in c# code on the server, how would I go about this?

As far as I can tell, you cant use asp.net tags (<asp:TextBox...) obviously as the client wouldnt be able to interpret them, so you have to use standard html tags (<input type="text"...). But then how would your c# code access these fields?

Essentially, Im trying to figure out the balance between using server controls and using standard html, and the pros and cons of each in asp.net.
 
nero120 said:
Thanks Mr Rubble!

Yet one more question for you if I may!

If I wanted to dynamically generate form fields (server controls) on the client side via javascript (say, when the user clicks a button, add a new row of input fields), to be submitted by the user and their values used in c# code on the server, how would I go about this?

As far as I can tell, you cant use asp.net tags (<asp:TextBox...) obviously as the client wouldnt be able to interpret them, so you have to use standard html tags (<input type="text"...). But then how would your c# code access these fields?

Essentially, Im trying to figure out the balance between using server controls and using standard html, and the pros and cons of each in asp.net.

Look into ATLAS there are controls that already do similar to that.
 
Back
Top Bottom