473,395 Members | 1,539 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,395 software developers and data experts.

Code in ASP or Class

Hello,

I am new with ASP.net. I have a simple question.
Where would it be better to have the code for a function ?
in the Control within the ASP file; or in a class (ex. C# class) and then the
function called from the ASP file.

Thanks,

Giovanni
Nov 18 '05 #1
4 901
hoz
It is better to organize your codes within a class, use OOP

"Giovanni" <jj****@hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Hello,

I am new with ASP.net. I have a simple question.
Where would it be better to have the code for a function ?
in the Control within the ASP file; or in a class (ex. C# class) and then the function called from the ASP file.

Thanks,

Giovanni

Nov 18 '05 #2
Put your code in a code-behind (class) and have your function called from
within it.
"Giovanni" <jj****@hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Hello,

I am new with ASP.net. I have a simple question.
Where would it be better to have the code for a function ?
in the Control within the ASP file; or in a class (ex. C# class) and then
the
function called from the ASP file.

Thanks,

Giovanni

Nov 18 '05 #3
If you want the code to be able to be reusable then you should put it in a
separate class.
Otherwise putting it in the code behind file is reasonable for a simple
application that is unlikely to grow much.

Here's some high quality research on the subject:
http://www.lhotka.net/ArticleIndex.a...ea=CSLA%20.NET

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Giovanni" <jj****@hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Hello,

I am new with ASP.net. I have a simple question.
Where would it be better to have the code for a function ?
in the Control within the ASP file; or in a class (ex. C# class) and then
the
function called from the ASP file.

Thanks,

Giovanni

Nov 18 '05 #4
You can't write a function outside a class.

If you write scripting in "the ASP file" you are writing in the Page class,
or rather, the class that inherits your CodeBehind Class, which inherits the
System.Web.UI.Page class. It is extremely important to understand these
principles of OOP in order to be successful with ASP.Net.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Giovanni" <jj****@hotmail.com> wrote in message
news:e9**************************@posting.google.c om...
Hello,

I am new with ASP.net. I have a simple question.
Where would it be better to have the code for a function ?
in the Control within the ASP file; or in a class (ex. C# class) and then the function called from the ASP file.

Thanks,

Giovanni

Nov 18 '05 #5

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

Similar topics

0
by: Dafella | last post by:
The following is code from Xeoport. It is suppose to access my pop3 account and load email into Mysql database. It's not inserting and there is no log or anything to tell me why. Here is the...
51
by: Mudge | last post by:
Please, someone, tell me why OO in PHP is better than procedural.
45
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes...
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)...
1
by: Alex Clark | last post by:
Hi all, Apologies for the cross-post but I can't determine if this is a VS .NET problem or a VB.NET language issue. I'm using .NET 1.1 SP1, VS 2003 EA, VB.NET. I'm coding a custom component...
6
by: TPJ | last post by:
Help me please, because I really don't get it. I think it's some stupid mistake I make, but I just can't find it. I have been thinking about it for three days so far and I still haven't found any...
2
by: rn5a | last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with the IDs 'txt1' & 'txt2' respectively. To use this user control in an ASPX page, the following Register directive will be...
7
by: praveenb000 | last post by:
Hi, every one on this forum.... I am new to web designing (using HTML/CSS). i designed a web page using HTML, Css with dream weaver. Here is the code i used for the desinging. it appears well...
3
by: knkk | last post by:
I am trying to include this code in the footer.template files of all blog templates: <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." :...
70
mideastgirl
by: mideastgirl | last post by:
I have recently been working on a website for an honors association, and have a lot of difficulty but have found help from those on this site. I would like to see if I can get some more help on a...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.