Author: saburius | Posted on: 9/27/2009 12:46:18 PM | Views : 387

Hi, In my codebehind pages I have lots data access code i.e. the one below that is mixed with conditional statements. How can I separate the data access code (ado) from codebehind, move them into a class file and call them or reference them from my code behind?
Or..does it matter if they are in the code behind mixed with the other code? I know this is not the best practice but it seems easier for me to edit my files in one place rather having the code all over the place.
However, I would like to learn the proper way of doing this so it is not looked down upon by other developers. Please help if you can.
Here is a simple example of the types of code I have a lot in my code behind pages.
#region Save Cart button click (Move to WishList) protected void btnSaveToWishList_Click(object sender, EventArgs e) { // if current user is not logged in if (!HttpContext.Current.User.Identity.IsAuthenticated) ...

Go to the complete details ...