Code Behind or not Code Behind

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.
3/24/2004 2:39:34 AM 91979 articles. 4 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 44
Get it on Google Play
Get it on Apple App Store

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.
3/24/2004 3:09:16 AM
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!
3/24/2004 3:35:22 AM
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...)
3/24/2004 7:21:37 AM
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 has 29 examples (C# & VB) to help beginners with ASP.NET.
1/6/2007 3:45:51 PM

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 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
1/6/2007 5:00:02 PM

Web resources about - Code Behind or not Code Behind -

An Incomplete Catalog of Donald Trump's Never-Ending Fabrications
There's a legal term applied to advertising called "puffery." For example, if Coca-Cola says that Coke is the best tasting soda in the world, ...

In taking economic war to Islamic State, U.S. developing new tools
By Yeganeh Torbati and Brett Wolf WASHINGTON (Reuters) - Since last month, U.S. warplanes have struck Islamic State's oil infrastructure in Syria ...

At least 5 people shot at Black Lives Matter protest in Minneapolis
At least five people have been shot near a Black Lives Matter protest in Minneapolis on Monday night. The protest was spurred by the death of ...

Google’s Got A Pretty Awesome Star Wars Easter Egg
Everyone loves Easter Eggs. There’s that thrill of uncovering a little secret that makes it so exciting. Now if you’re after more Easter Eggs, ...

Suspect dead after shooting kills 3 in Ohio, injures 4th
COLUMBUS, Ohio (AP) — Columbus police said they are trying to determine why a man fatally shot a couple and their 7-year-old son and critically ...

Apple Pay reportedly coming to China by February 2016
Apples mobile payment service may finally launch in its largest potential market outside the U.S. as early as the first quarter of 2016. As ...

ACLU sues Indiana governor over refusal to resettle Syrian refugees
Pence is one of more than 25 U.S. governors, mostly Republicans, who have publicly called on President Barack Obama to stop resettling Syrian ...

FAA publishes drone registration recommendations: You must be 13 to enter
The Federal Aviation Administration has released a task force’s recommendations for setting up a registration system for recreational drones ...

In fact: Mali hotel attack- Lessons from the relentless jihad in the Sahara sands
The attack should have reminded the world just what the war against Islamist violence is about: savagery can only too easily bury in the sand ...

Futurama is coming back as a mobile game
After being canceled, resurrected, and canceled again, Futurama is coming back — this time as a mobile game. Matt Groening's sci-fi cartoon universe ...

Resources last updated: 11/24/2015 7:56:33 AM