473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Code Behind Question

Hi I am designing an ASP.net app. Just wanted some opinions on code behind
options. My idea is to have a code behind file that the controls will
reference and have ascx files for the controls. Then have the aspx pages
call the controls. Is this a good approach? I wanted to throw all my
business logic in to the code behind file and then on the aspx pages that
use the controls just refernce the ascx files. Is this the correct
approach? Should I bypass the ascx controls if they are not fancy customer
controls just like a datagrid? Also I connect to SQL back end in the app
and get different data for some of the datagrids that will be on the main
page? Is it better to put the ADO.net connection logic in to the ascx
files? or better to use the Code Behind? Thanks for any opinions.

Regards,
Chris
Nov 18 '05 #1
1 1253
Do not think of CodeBehind as a file, or you're already in trouble. It isn't
a "file" to your application. It is a class definition. It is the class
definition for a given Page. The class definition is simply split into a
Template (.aspx) and a class definition.

A Page is a System.Web.UI class, which means that it is a User Interface. As
such, it isn't a good idea to put much (if any) business logic into it. Your
business logic should reside in Business classes, classes that work with
data and have no User Interface. The Page is then the User Interface, with
all the User Interface elements in it, and the only logic in the Page should
deal with presenting the data from the data classes in the page, and
allowing the User to interact with it. The Page should interact with the
business objects via the business class programming interface.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.

"Chris Kettenbach" <ch***@piasd.org> wrote in message
news:qh*******************@newssvr13.news.prodigy. com...
Hi I am designing an ASP.net app. Just wanted some opinions on code behind options. My idea is to have a code behind file that the controls will
reference and have ascx files for the controls. Then have the aspx pages
call the controls. Is this a good approach? I wanted to throw all my
business logic in to the code behind file and then on the aspx pages that
use the controls just refernce the ascx files. Is this the correct
approach? Should I bypass the ascx controls if they are not fancy customer controls just like a datagrid? Also I connect to SQL back end in the app
and get different data for some of the datagrids that will be on the main
page? Is it better to put the ADO.net connection logic in to the ascx
files? or better to use the Code Behind? Thanks for any opinions.

Regards,
Chris

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

242
by: James Cameron | last post by:
Hi I'm developing a program and the client is worried about future reuse of the code. Say 5, 10, 15 years down the road. This will be a major factor in selecting the development language. Any...
171
by: tshad | last post by:
I am just trying to decide whether to split my code and uses code behind. I did it with one of my pages and found it was quite a bit of trouble. I know that most people (and books and articles)...
6
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp;...
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
7
by: Alan Silver | last post by:
Hello, I am just looking at VWD and seeing what needs doing to take an existing site I've written by hand and importing it into VWD. I've already discovered that I need to rename my code-behind...
7
by: Alan Silver | last post by:
Hello, I have installed the 2.0 framework, and am looking at converting some of my 1.1 pages to use partial classes. I don't (yet) have VS2005, so I'm doing this by hand, but am having problems....
2
by: walter | last post by:
Hi, when I add a new page in my asp.net 2 project and put some controls there, everything works fine until I move the code behind into App_Code folder.--When I compile , it tells me that control...
1
by: archana | last post by:
Hi all, I am new to asp.net. I have one question regarding code- behind model. I have written page_load event in code behind as well as in aspx page. Means i am doing mixing of code-behind...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.