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.