473,513 Members | 2,275 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Classes functions....help!

Hi All,

I'm new to asp.net (Migrating from 'Classic' ASP)

I'm having troubles working out classes, functions etc...

Current situation is this:

index.aspx displays datalist with links to sites - If no link found in DB, I
want to display a message instead. I worked out I need a function to do this
(No if statements based around DB values allowed in datalist)

Questions are:
- Where do i build the function? In a seperate class file? In the code
behind for index.aspx?

- How do I then call this function/class? I understand the syntax of
actually calling the function, its more a case of how do I make the
function/class available to index.aspx?

- How do I return a value from the function/class? I want to input 2
values - ID and Domain, if domain is empty, I want to return 'No Site
Listed' if not, I want to return the domain.
Sorry if this is all a bit vague - I may well be asking the wrong
questions???!

Thanks,
Simon.
Nov 18 '05 #1
1 1371
Hi Simon,

You need to study up on object-oriented programming, because .Net is fully
object-oriented. If you don't understand OOP, you're lost. I can give you a
brief here, but you really need to study up on your own until you "get it."

The first thing you need to understand is the difference between procedural
and object-oriented programming. The difference is that in procedural
programming, the instructions are executed in a specific order, with a
number of side trips to execute functions. In object-oriented programming,
there are logical groupings of functionality and data that are called
classes. A class is simply a container for functionality and data. There is,
of course, a procedural aspect to OOP, but rather than moving in an orderly
fashion through a procedural path, execution jumps around from one object to
another. OOP also includes events. An event is when a piece of code informs
the Operating System that something significant has happened, and the OS
broadcasts that news to any class listening for it (via an event handler).
The event handler then independently executes the code that handles the
event.

The chief components of OOP are:

Encapsulation - Classes have the ability to hide or reveal data and
functionality contained within them. By the use of Private, Public, and
other class scopes, you can hide anything in a class that you don't want
accessed from outside the class (a bit oversimplified, but hopefully you get
the idea). It's all a matter of scope.

Inheritance - Classes can "inherit" from other classes. If a class inherits
another class, it has (a bit oversimplified again) all of the data and
functionality of the class which it inherits. This is particularly useful
for writing reusable and compact code. For example, if you want a text box
to do everything that a TextBox class does, but add some functionality to it
as well, you can simply declare a class that inherits TextBox, and add the
funtionality to it.

Polymorphism - Classes can have the same programming interface, but behave
in different ways. This is done by inheriting other classes and overriding
certain methods and properties. It can also be done by the use of
Interfaces. An Interface is like a contract that says "if you use me, you
must include such and such a method or property, but it can operate any way
you want it to." For example, both trucks and cars are of the same type
(vehicle). However, the implementation of vehicle will be different in a
truck than in a car.

Functions in procedural and OOP work basically the same. The chief
difference is that functions are encapsulated in classes with OOP.

Google Object -Oriented Programming to get a better picture. This is less
than a thumbnail. I would not recommend trying to write a single line of
code without understanding the basics of OOP.

Also, you may want to download the FREE Microsoft .Net SDK:

http://www.microsoft.com/downloads/d...displaylang=en

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

"Simon Harris" <to***********@makes-you-fat.com> wrote in message
news:Os**************@TK2MSFTNGP15.phx.gbl...
Hi All,

I'm new to asp.net (Migrating from 'Classic' ASP)

I'm having troubles working out classes, functions etc...

Current situation is this:

index.aspx displays datalist with links to sites - If no link found in DB, I want to display a message instead. I worked out I need a function to do this (No if statements based around DB values allowed in datalist)

Questions are:
- Where do i build the function? In a seperate class file? In the code
behind for index.aspx?

- How do I then call this function/class? I understand the syntax of
actually calling the function, its more a case of how do I make the
function/class available to index.aspx?

- How do I return a value from the function/class? I want to input 2
values - ID and Domain, if domain is empty, I want to return 'No Site
Listed' if not, I want to return the domain.
Sorry if this is all a bit vague - I may well be asking the wrong
questions???!

Thanks,
Simon.

Nov 18 '05 #2

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

Similar topics

3
3437
by: Logan K. | last post by:
What is a PHP class? I've seen a lot of talk about these and how they can help you out, but I've never seen a very good explanation. I've been working with PHP for just over 6 months and usually...
1
741
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
45
3556
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...
3
1420
by: John J | last post by:
I requested help with some code in a previous thread, as requested in the feedback, below are the .cpp and .h files for all three classes (Entry, Race and Yacht). The three classes are all...
5
3472
by: Benne Smith | last post by:
Hi, I have three enviroments; a development, a testing and a production enviroment. I'm making a big application (.exe), which uses alot of different webservices. I don't use the webservices...
4
2109
by: Chris F Clark | last post by:
Please excuse the length of this post, I am unfortunately long-winded, and don't know how to make my postings more brief. I have a C++ class library (and application generator, called Yacc++(r)...
7
1749
by: alternativa | last post by:
Hello, I have a few questions concerning classes. 1) Why some people use default constructos, i.e constructors with no parameters? To me it doesn't make any sense, is there something I should...
5
1642
by: Alex | last post by:
Hi, this is my first mail to the list so please correct me if Ive done anything wrong. What Im trying to figure out is a good way to organise my code. One class per .py file is a system I like,...
19
1813
by: dl | last post by:
I'll try to clarify the cryptic subject line. Let's say I have a base class 'GeometricObject' with a virtual method 'double distance (const GeometricObject &) const'. Among the derived classes...
0
7171
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...
1
7114
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
7541
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...
0
5693
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5098
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.