Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with Imports and SqlConnection
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00707445
Message ID:
00707797
Views:
22
>I have run into a problem using Visual Studio.NET and a code-behind page. I am reading a couple of ASP.NET books, and all the examples have the code in the .aspx page. It's my understanding that it's better to put the code in the code behind page. Is that correct?

There are at least 3 reasons for using code behind:

1) Separation of html and code, as you already know.
2) Code behind is a class. That means that you can inherit from a codebehind class (which is just a sublass of the webform Page class). This can be a great productivity boost and its the approach that I take in my ASP.NET framework. You cannot derive from script code in the aspx page.
3) Codebehind is compiled, script in aspx is not. Of course this means that is faster to execute. Also this is the one small drawback: if you make a change to the codbehind, you have to compile it before you will see the change on your web page. Script in the aspx is interpreted so changes will be reflected immediately. Thats why Web Matrix does not use codebehind and why I don't use Web Matrix.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform