Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

To include, or not to include...

While dabbing around with C#, VB.NET, and ASP.NET; I've allowed myself to play around with several IDE's.  C#Builder, WebMatrix, and VS.NET (2002 & 2003).  In using those, there seems to be two ways of creating ASP.NET pages:

Way one, which is the WebMatrix favorite, involves putting your code in-between SCRIPT tags.  This is very reminiscent of the ASP and PHP way of writing code.

Way two, which VS.NET and C#Builder prefer, is to do your coding in a file called filename.aspx.cs (or filename.aspx.vb, depending on your language) and put your markup in filename.aspx.

My questions to you experts:

Question one, which way, if either, is better?  Will I be losing any performance if I just stick my C# or VB.NET code in between SCRIPT tags?  Is having everything in a filename.aspx.cs file better somehow?

Question two, is there a good reason to use an IDE for web applications?  I'm trying to learn C# and VB.NET with IDE's, since they seem to be IDE friendly languages.  However, both C#Builder and VS.NET seem to make building web applications a bit cumbersome than when I do PHP in a text editor.  Aside from having a class browser built-in to the code editor, am I going to lose anything if I go back to notepad?

Thanks, everyone.

Andrew Burton
Wednesday, June 23, 2004

If you've got your code in the code-behind *.aspx.cs files, then you can obfuscate and compile the code into a dll, to try to keep most (most) people from looking at your code.

If you put your code in the *.aspx files, then you have to distribute it, as-is.

I can't think of anything else outside of IDE integration type stuff...

Greg Hurlman
Wednesday, June 23, 2004

"Question one, which way, if either, is better?  Will I be losing any performance if I just stick my C# or VB.NET code in between SCRIPT tags?  Is having everything in a filename.aspx.cs file better somehow?"

I don't believe there is a performance difference.

One of the primary benefits of having the code in a .CS file is a cleaner separation between the HTML, Javascript, etc and the C# code the drives the page. My ASPX pages normally just consist of HTML and Javascript. All of the "meat" is in the busines objects code, which in turn is called from the code in the .CS file.

Mark Hoffman
Wednesday, June 23, 2004

Thank you both!  That answers my question.

Given that there's no performance enhancements, I think I'll ditch VS.NET for the time being, and return to Notepad.  Thanks!

Andrew Burton
Wednesday, June 23, 2004

You should check out #develop, a GPL'd IDE that is trying to be an opensource Visual Studio - I've only played with it, but I've heard good things...

http://www.icsharpcode.net/OpenSource/SD/

Greg Hurlman
Wednesday, June 23, 2004

In any case, if you must code in a text editor (I'm a card-carrying member of the Cult of the IDE, but we don't kill heretics), get something better than Notepad. Coding without syntax hightlighting and some minimal autocompletes is not something you want to do.

Dave Rothgery
Wednesday, June 23, 2004

I assume you won't be utilizing any of the event model that ASP.NET brings to the table? How about fully developing user controls?

I can't imagine that that would be too much fun to write in notepad.

If you're going to use "ASP.NET" no different than ASP, what are you gaining by switching? Off the cuff, it sounds like you have no idea of the power that .NET can unleash.

Pardon Me Sir...
Wednesday, June 23, 2004

I put as much code as possible into compiled code-behind classes, to leverage the compile-time error checking.

Ian Olsen
Thursday, June 24, 2004

"In any case, if you must code in a text editor..."

Well, so far, I find myself still using VS.NET.  The drop-down list that lets you see parts of a class is a small feature I'm finding hard to let go of just yet.  Having something automatically handle prowser and Cassini launching is nice too, thought that's more of a C#Builder and WebMatrix feature.

"Off the cuff, it sounds like you have no idea of the power that .NET can unleash."

I really don't, you're right.  On a scale of 1-to-10, one being a complete newbie and ten being the VS.NET 2005 guys, I rank myself somewhere near four.  The biggest reasons I'm using .NET right now are to learn about it (and C#) and because .NET has some very nice image editing components (GDI?) -- ImageMagick is nice, but you can't beat having pre-installed libraries with multi-format functionality.

Andrew Burton
Thursday, June 24, 2004

At my company we develop our source code in notepad, dreamweaver, and VS 2003.  When I use VS, I use it purely as a code editor, using a 'Class Library' project type, as opposed to an 'ASP.NET Web Application'.  Then we use the command line compiler to compile the source into .dll's.  This is great because I get all of the cool features of VS like code highlighting and intellisense, and I still get to manage the HTML as I please

benjer
Friday, June 25, 2004

There is a 3rd way to do it. Put *all* of you code in to cs which will be complied into a dll.

Do this by creating IHttpHandler's. (http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebIHttpHandlerClassTopic.asp)

To assist you with writing HTML from code, use the HtmlTextWriter (http://msdn.microsoft.com/library/en-us/cpref/html/frlrfSystemWebUIHtmlTextWriterClassTopic.asp?frame=true).

Using this methodlogy may take longer devlopment, but will result in better code.

Gary van der Merwe
Tuesday, June 29, 2004

*  Recent Topics

*  Fog Creek Home