View Single Post
  #2 (permalink)  
Old March 28th, 2012, 02:00 PM
Imar's Avatar
Imar Imar is offline
Wrox Author
Points: 72,035, Level: 100
Points: 72,035, Level: 100 Points: 72,035, Level: 100 Points: 72,035, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,079
Thanks: 80
Thanked 1,587 Times in 1,563 Posts

Hi Tulsi,

That's one of the problems with web forms and code behind. It could be anything depending on the code you write. If you use

myControl.BackgroundColor = Color.Blue;

it's the presentation layer. If you calculate a discount based on the number of items the customer has in his cart, it's business logic. If you set up a SqlConnection object and access the database, it's the data access layer.

In general, you should strive to write as little code in Code Behind and instead delegate to the appropriate layer. This way, the Code Behind becomes more of an orchestrator / controller as in MVC.


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Reply With Quote