Ok i am confuse now.... A lot of books are showing pages without code behind (the code is integrated in the .aspx) Is it better to use the code behind or not. Is there any difference between using VB.NET or C#.NET except for the code synthax.
Thank you and come again.
A lot of samples show inline code just for simplicity.. i personally use code-behind because I like to seperate my code from presentation.
As for VB.NET or C#, its your preference.. there is no difference really when its all said and done.
From a purely mathematical sense, having everything in a single file would seem to make more sense…
The experts maintain that separating “code” from “presentation” is the way to go. I am still unclear on how code is eliminated from the presentation layer. For example, ASP.Net HTML “code” contains controls (ie: labels, textboxes, etc) that use id’s. All it takes to screw everything up is to change an id in the “presentation” layer and the “code” that references the changed id will now break. To me the presentation and code layers are still too closely related.
So, the real answer may be that it is a personal preference based on your environment.
Just my two cents worth!
I'd go for code-behind any day of the week!
I think it results in a much more readable code, with only tags in the .aspx page and all the functionality in the code-behind class.
I personally used some inline code when I first started out with ASP.NET but I think it was only because I was accustomed to it from classic ASP, nowadays I never put any inline code in my aspx pages.
Worth noting is also that in some cases the Web-view of Visual Studio refuses to show your pages if you have inline code in it.
Just my 2 öre (I'm from Sweden, so I don't have and cents...)
I'm looking for a good tutorial (or tutorials) that help a beginner with using 'code behind'. I'm making simple pages (math operations, counting loops, etc.) to get started but I want to do it using code behind (assuming this is practical).
Larry Dechent - Sampson Coatings
www.wemakebetterpaint.com has 29 examples (C# & VB) to help beginners with ASP.NET.
Code behind is a good think, but.... (almost everything has its 'but')
Code behind separates your code from presentation layer, so it si good to use code behind, but better is to use class libraries - your code is more separated and your application is more object oriented - and in asp.net 2, you should completely avoid any code in most cases (thinking about databinding and objectdatasource).
So, my advice is - use class libraries and when necessary, use code-behind, but I'm not friend of large code-behind files.
programmer + caffeine + taurine = new application