PDA

View Full Version : Why use code behind in ASP.NET?


david7777
05-06-2003, 11:05 AM
I have searched the net for information on code behind - like what Visual Studio.net uses.

From what I have found, it seems that it is basically used to seperate the server code from the design. The reason to do this would be to make things neater and more easily readable.

Why do this? - To make life easier for development teams and prevent the user interface designer from messing with the server side code.

Ok, so you're not in a team, so why do it now? I guess it would be the smart thing to do in case your site becomes big enough to need a development team. Or better yet - If you use code behind as a standard, you will know how to do it when asked or when you need to :)

Are there any other advantages / disadvantages to code behind?

allida77
05-06-2003, 02:29 PM
When compiled they both run at the same speed. Code-behind gives you a complete seperation between code and content. Complete Code-behind is more of the MS way and really requires you to have vs.net. Personally it is preference to which style of coding you prefer. I do not use vs.net so I dont have a complete seperation between code and content. I will normally pull out frequently used code and build classes for a project. When it comes to things like headers and footers I will put them in ascx files.

I do not think there is a wrong or right way but it is whatever is best for the coding environment. One of the advantages is that one programmer can write all the code (code-behind) and the other only has to worry about the design (content).

angiras
05-06-2003, 10:19 PM
you don't need VisualStudio to write your code behind, even with asp 2 and 3 I have ever tried to separate html css and vb script

I have started ASP Net with beta one and only edit plus as editor
and never do anything else than codebehind

it's the only way to write a good code, and to be ready for evolution

of course vS is great... but expensive :-((

david7777
05-07-2003, 11:25 AM
Thanx guys. Another quick question - Is there any diffirence in performance between compiled dll's and uncompiled files? In other words - should i try use pre-compiled dll's, or should i just let the server compile on the fly?

angiras
05-07-2003, 01:19 PM
but the dll is compiled one time , and then automaticly recompile at the first visitor

you must have a dll into the /bin folder

david7777
05-07-2003, 01:59 PM
Only some of the time - You can use src instead of CodeBehind to indicate where the code is, and if src is used, no dll is required...

allida77
05-07-2003, 02:00 PM
no there is no difference in performance

david7777
05-07-2003, 04:09 PM
Thanx addict, uhhh... i mean allida77 :D (posts: 300)