Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET random thoughts 4

Status
Not open for further replies.

link9

Programmer
Nov 28, 2000
3,387
US
Hello everyone --

Was lucky enough to be able to attend a conference this past week concerning .NET, and specifically, ASP.NET. Came away with quite a bit, and wanted to share.

I'd first like to start off by saying that ASP classic is dead. ;-) Forget it. This new stuff is so much better, it's just ridiculous to still code ASP classic.

Ok, so I tried to after each session, bang out a simplistic example of everything so that I could take it back to work and share with employees. I have included two projects as zip files that have these files in them. They are anything but exhaustive, but they do touch on many of the things that I found most interesting, including among other things, compiling and using a separate assembly (the new approach to COM) outside of your current project, the bare bones beginning to setting up a hierarchical namespace to organize these assemblies, basic examples on data access and databinding, global storage of connection info (and how to modify web.config and machine.config) and other values, user controls, and so on and so forth...

web project:
assembly(component) project:

The cmi.zip file includes two classes... the first converts string data into its ASCII equivalent for HTML storage (w/o the need to worry about special chars and such), which I find useful many times. The second just takes a string argument, and converts it to it's .NET constant equivalent for aligning text programatically in user controls. You'll see where it's used in the examples where I consume the user controls, which is under the graph subdir of the project.

They're both very simplistic.

And here are some random notes that I put into a .txt file during the week. Just things that I thought might be helpful to someone trying to get a handle on the technology, and how to use it effectively:

Most of the notes I put in here are specifically addressed in the test web project that I posted in the .zip file, so if you look at all the files, you'll find working examples of most of it.


One other thought that just hit me is the fact that the dataset has a .writeXML method that will serialize the data in a dataset into a well-formed xml document. It also has a reverse .readXML that expects a well formed document.

This can facilitate what used to be referred to as 'rds' (remote data services), or storing of data on a user's machine so that they can browse real data offline. The key here is to write the xml with an option (you can find all the overloaded methods in the .net documentation) with the 'diffgram' option. This will store metadata about the dataset, as well, and keep track of what's been updated and such, so that uploading the data back to the data store is pretty easy. I have some examples on how to do this, as well, and if anyone is interested, I can post them. The examples came from Dino Esposito (Cutting Edge column editor for MSDN mag), and they're pretty good, although you can also go to msdn online to find much of the same type of stuff from his column, complete with code.

On top of rds, you can really use this to store data on your server as well, which could be used effectively to make your site more scaleable, relying less on the data store behind the scenes, and instead using file I/O to present data to a user (file I/O has also been vastly improved in .NET -- especially for xml docs). A pseudo-caching strategy. Depending on the application, it could be very useful.

I hope you guys/gals find this information useful. Comments on how I might improve stuff here is not only welcomed, but requested...

:)
paul

ps. You may have to modify the references section of the test project, as there's no telling where you might put these files... the reference in question will be to 'cmi'. Just remove it and re-add it to point to wherever you save the cmi project. You might also want to just axe any reference you see to 'webControls'. This was my first stab at writing a globally available web control, and to date, I have not gotten it working properly. Just kill it, and everything should compile ok.
penny1.gif
penny1.gif
 
Another thing:

Hate the default grid layout of your pages? Can't find how to change it?

Cruise over to your installation directory\vb7\VBWizards\WebForm\Templates\1033

and find WebForm.aspx... modify as you see fit --

There's a C# directory there, which you can drill down into the same way if that's your language.

Adiditionaly, you can put boiler plate code behind templates in there, too. Find those at:

installationDirectory\VB7\DesignerTemplates

You'll see a bunch of appropriately named templates in there. Careful in there, though. There are some things in there that, if you take them out, you'll screw up the workings of your new pages. Instead, you might want to add things to these guys, instead of removing.

Actually, these folders are full of stuff you can do to add boiler plate types of things to VID. In Visual Studio .NET, notice that the directory structure mirrors what you see when you get your choices of what to add when you select "new xxx" from the menus in VID?

Well, this is where it's reading from, so feel free to just make your own from scratch (probably cutting and pasting important plumbing from the existing files) and then adding your own... possibly default style sheets or whatever. Endless possibilities here.

:)
paul
penny1.gif
penny1.gif
 
Hey Paul,
Thanks for posting all this info. I'm sorry I missed the conference...would've really liked to have gone! :-(

I'll check out your samples in a bit (or tomorrow...it's getting pretty late here), but I'm curious...what feelings or suggestions did you get while at the conference regarding the "best language to use" with ASP.NET?

Is there more functionality and/or power with C#, or VB, or C++? That's one thing I've been wondering for a while. Any comments you can make on this would help me out a lot as it would direct me to venture into the .NET world. Just curious what (if anything) was said or covered at the conference on this topic.(?) -Ovatvvon :-Q
 
This topic was covered.

As far as who is planning to use what... it was split right around 50/50. A show of hands was requested at the closing session, and it couldn't have been closer to half and half.

As far as performance, numbers were given in the terms of pages/second served from MS's petshop sample app.

I think the total numbers were somewhere around 300-400 pages/second (it might have been more... I really can't remember), and the difference between the two languages were that C# edged out VB.NET by about 5 pages/second. A difference that's hardly measurable when you talk percentages.

So the basic concensus is that it really doesn't matter what language you use. It's strictly personal preference.

It would not be hard to learn C#, though. It really is a beautiful language. About half the examples shown during the week were given in C#, and they were very easy to follow. Coming from C++ background (my first language), I can tell you that I hated the whole header file structure in C++. That is now gone in C#, which I think is probably the best thing. The code is much more self evident with Using statements and such to pull in your parent classes (looks alot like JAVA, really, which is also a great language).

Personally, I think I'm just going to stick with VB.NET. It's a very nice language, and I'm probably most comfortable with that syntax.

**kachink** :)
penny1.gif
penny1.gif
 
Thanks for all that info Paul. Has cleared up a bunch of stuff for me...and I'm sure a bunch of other people. -Ovatvvon :-Q
 
I currently use ASP but have been seeing all the fuss about .NET and am wondering if I switch to it, what is the learning curve? Do I have to add any .net support to my PWS on my desktop? Should I consider taking a sit-in course on the subject? I basically learned ASP on my own and actually spend quite a bit of time looking up stuff in my books.

Jerry Scannell
 
You should consider taking a course on it. If you are familiar with object oriented principles, you will feel right at home (unlike traditional ASP), but if you aren't familiar, then a course would definitely help straighten out the learning curve.

There's no question whether or not you should switch, though. The only question is... when?

There are so many new twists on development now, and so many new powerful tools that you can take advantage of. The thing is, though, that you can still write spaghetti code if that's what you want to do, but if you take advantage of the new tools available, you'd swear you were developing for the desktop, rather than a web platform.

It's really quite amazing.

In the examples I posted up there, there are some very simple examples of good ways to re-use your code. The graphing user controls that I wrote take advantage of this technique.

And I also wrote a small component (now called assemblies) that I use in another page (the convert example)... doing this type of thing has never been easier.

paul
penny1.gif
penny1.gif
 
Oh, and I'm fairly sure that ASP.NET won't run on PWS.

I know it won't run on NT4, and so I'd really be surprised if PWS supported it.
penny1.gif
penny1.gif
 
Being that it's a compiled-based language (now), does that mean you cannot program using notepad then? -Ovatvvon :-Q
 
Absolutely not. Actually, there's really not anything you can't program in notepad. COBOL --> C#. everything can be done in notepad.

Only difference is now that you have to compile your pages and assemblies prior to their being available for browsing. The SDK comes with a command line interface for .NET (as does VID) that you can use to manually compile pages written in any editor.

There's only one real advantage... understanding what's going on under the sheets. You don't get alot of the automatic plumbing that comes de-facto with VID. You have to make sure everything is in the right place, and have to compile everything by hand. So while this does give you a better understanding of the technology, you do lose alot of the RAD benefits of ASP (or VB, or C#, or whatever).

It's cool to play with, but IMHO, definitely not the way to go in a production environment. I'm sure someone will disagree... but they'll still be monkeying with file structures when the rest of us go to print.

;-)
penny1.gif
penny1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top