tags:

views:

58

answers:

2

i want to know that why we use code behid approch. if there is some advantage then plese share to me ? as we know that there is two methode for writing server side code for aspx.file

  • code-behind approch in which we usually we seprate our server code aspx.cs file from aspx file
  • we can directly write server side code in aspx page by writing //server side codebefore html tag ?

so i wnat to know that is ther any authentic reasion which provide advatage in code-behind approch.

+2  A: 

You should strive to separate UI layout from UI or business logic. Those who use codebehind benefit from the advantages of compile-time warnings, type safety, and better debugging support.

Check this article - http://articles.techrepublic.com.com/5100-10878_11-1049844.html

EDITED: this one is helpful too to give information of code-behind pages - http://www.java-samples.com/showtutorial.php?tutorialid=1084

Sachin Shanbhag
Code-in-front has those same advantages, doesn't it?
bzlm
In traditional ASP, the interweaving of script with HTML can produce source control nightmares and difficult-to-maintain ASP pages. ASP.NET addresses this problem by giving programmers the ability to separate the executable code from the presentation code. Updated another link for more details in answer
Sachin Shanbhag
A: 

It helps prevent spaghetti code with a mix of markup and code, which is hard to maintain and review.

Tom Gullen