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

.ASP Properties vs Attributes

Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.


Nov 16 '05 #1
13 3106
Patrick,

I don't know your book, however an attribute is used as they belong to HTML
controls (which the servercontrols on the client side are as well). Height,
Width on the client side is an attribute.

While when you are using them in your code in C# directly it are properties.

Maybe I can show it you with this piece of code.
\\\
private void Page_Load(object sender, System.EventArgs e) {
if (!IsPostBack)
{
this.Button1.Text = "Send Mail";
this.Button1.Attributes["onClick"] =
"window.location='mailto:no*@non.com?subject=C or demo&body=I hope this
helps?';";
}}
///
In this.Button1 is Attributes a property that sets an Attribute in the HTML
form (clientside)

I hope this helps?

Cor

"Patrick *" <wa********@all.here>
Reading a book on .ASP .NET I am getting a bit mixed up as to the
difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good
definitions?
Both with respect to controls.


Nov 16 '05 #2
Patrick * wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.


Not having the book text available it's hard to tell wether they are
mixing up the words or if you're mixing up attributes and properties.

The .NET definition of the two are:

A property is something part of a class, like Name. You access it like this:

obj.Name = "Hello";

or similar. This executes some code in order to store the new value in
the object.

For components/controls you drop on form, these are the things you get
in the Properties window when you select it.

An attribute is something different and is only relevant in source code.

for a class, defined like this:

public class YourClass {...}

an attribute could be applied to it like this:

[AttributeName(parameters to attribute here)]
public class YourClass {...}

Some attributes are used to tell the compiler to do something specific
with whatever the attribute is applied to, other attributes are simply
stored in the assembly for future reference. For instance, you can
iterate through all types in an assembly and check if each has a
specific attribute applied to it.

If your book talks about properties and calling them attributes, well,
then I don't know what they're doing.

A html tag, like <a href="xyz"> has attributes in the sense that "href"
is an attribute of the "A" tag. ASP.NET controls store some of the
property values in attributes like this. This could be what they're
talking about.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
mailto:la***@vkarlsen.no
PGP KeyID: 0x0270466B
Nov 16 '05 #3

"Cor Ligthert" <no************@planet.nl> wrote in message
news:eg**************@tk2msftngp13.phx.gbl...

Hey guys, these explanations, however valuable are no definitions.
Nov 16 '05 #4
Zach,

What is a definition when some people calls something an attribute and the
others a property.

Asked is how it is used in ASPNET and there they are mixed up when it is on
clientside or on serverside.
http://msdn.microsoft.com/library/de...htopic.aspWhen you want a definition than you can look in a dictionary however incomputer bussiness definitions are not always used right.http://dictionary.reference.com/sear...=attributeJust my thoughtsCor"Zach" <cs**********@freeler.nl>> Hey guys, these explanations, however valuable are no definitions.>>

Nov 16 '05 #5
I don't know why it became all together

Zach,

What is a definition when some people calls something an attribute and the
others a property.

Asked is how it is used in ASPNET and there they are mixed up when it is on
clientside or on serverside.
http://msdn.microsoft.com/library/de...htopic.aspWhen you want a definition than you can look in a dictionary howeverincomputer bussiness definitions are not always used right.http://dictionary.reference.com/sear...=attributeJust my thoughtsCor

Nov 16 '05 #6
It was too much work to make this message not trying it to get it sent
correct.

What is a definition when some people calls something an attribute and the
others a property.

Asked is how it is used in ASPNET and there they are mixed up when it is on
clientside or on serverside.

http://msdn.microsoft.com/library/de...es/width_2.asp

---

http://msdn.microsoft.com/library/de...widthtopic.asp

When you want a definition than you can look in a dictionary
howeverincomputer bussiness definitions are not always used right.

http://dictionary.reference.com/search?q=property
----

http://dictionary.reference.com/search?q=attribute

Just my thoughts

Cor
Nov 16 '05 #7
The terms attribute and property are related in that, in the design phase of
a project, you define attributes of objects - for instance, an attribute of a
car is its color. When you create a car class, you then create a color
property to describe that attribute. It is this relationship that it sounds
like, to me, that you may be getting confused about from your book.

I say this, because there's another attribute definition which is different
enough from a property that it shouldn't be as confusing - the
System.Attribute class and objects created from that class. You can read the
values of attributes in code and respond appropriately.

In Visual Studio .Net, there is an attribute class. Attributes are placed
into your source code to describe code or control compiler behavior. You can
read the values of the attributes and act accordingly in your code.

"Patrick *" wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.


Nov 16 '05 #8
The terms attribute and property are related in that, in the design phase of
a project, you define attributes of objects - for instance, an attribute of a
car is its color. When you create a car class, you then create a color
property to describe that attribute. It is this relationship that it sounds
like, to me, that you may be getting confused about from your book.

I say this, because there's another attribute definition which is different
enough from a property that it shouldn't be as confusing - the
System.Attribute class and objects created from that class. You can read the
values of attributes in code and respond appropriately.

In Visual Studio .Net, there is an attribute class. Attributes are placed
into your source code to describe code or control compiler behavior.

"Patrick *" wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.



Nov 16 '05 #9
I think Lasse's post is probably closest to the answer you are looking for,
since you are speaking about ASP.Net.

Attributes belong to Html Elements, such as the table tag. They are
contained inside the opening tag and specifiy behaviors and look and feel
information, like Cellspacing.

Properties belong to controls, components, and classes.

Both serve the same purpose in the grand scheme of things. It's a matter of
convention for the type of language or technology you are dealing with.

"Patrick *" wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.


Nov 16 '05 #10
Thomas,

Did you ever set the EnableViewStateen = true of a webpage control and did
than look at the source code of that HTML page.

Than you will see that what is in C# a property is presented in the Client
side as an attribute to use in JavaScript again as a property.

Cor

"Thomas Taylor" <Th**********@discussions.microsoft.com>
I think Lasse's post is probably closest to the answer you are looking for,
since you are speaking about ASP.Net.

Attributes belong to Html Elements, such as the table tag. They are
contained inside the opening tag and specifiy behaviors and look and feel
information, like Cellspacing.

Properties belong to controls, components, and classes.

Both serve the same purpose in the grand scheme of things. It's a matter
of
convention for the type of language or technology you are dealing with.

"Patrick *" wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the
difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good
definitions?
Both with respect to controls.


Nov 16 '05 #11
Patrick * wrote:
Reading a book on .ASP .NET I am getting a bit mixed up as to the difference
between "property" and "attribute" as the terms don't seem to be used
consistently in the book I am reading. Can anyone give two good definitions?
Both with respect to controls.

In the .Net environment, a property is any member value of a class that
has accessors (get/set) as follows:

class SomeClass
{
private int classInt;
public int ClassInt
{
get { return classInt; }
set { classInt = value; }
}
}

WHen you do reflection on this class for the properties, you only get
information on items such as this. An attribute is a directly
accessible member variables. If classInt where public, it would also be
an attribute.
Nov 16 '05 #12
Hi,
C# Code Perspective

Property = A functional piece of code where an action can take place.
But where you can get confused is LOGICALLY a property is an Attribute
of the object which holds it but physically it is a functional piece of
code.

Attribute = A piece of code which describes code to the compiler. An
instance of System.Attribute is Run-Time meta-data which allows the
compiler to do certain things when you append an attribute to your code.

Attributes are most commonly used with Reflection Techniques.

Hope this helps.
Happy Coding,

Stefan
C# GURU
www.DotNETovation.com

"You always have to look beyond the horizon and can never be complacent
-- God forbid we become complacent."

Jozef Straus

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #13
Stefan,
C# Code Perspective
The question is asked from an ASPNET perspective. See the subject and the
question from the OP.

Cor

"Stefan" <we******@dotnetovation.com>
Hi,


Property = A functional piece of code where an action can take place.
But where you can get confused is LOGICALLY a property is an Attribute
of the object which holds it but physically it is a functional piece of
code.

Attribute = A piece of code which describes code to the compiler. An
instance of System.Attribute is Run-Time meta-data which allows the
compiler to do certain things when you append an attribute to your code.

Attributes are most commonly used with Reflection Techniques.

Hope this helps.
Happy Coding,

Stefan
C# GURU
www.DotNETovation.com

"You always have to look beyond the horizon and can never be complacent
-- God forbid we become complacent."

Jozef Straus

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #14

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

Similar topics

0
by: Nigel Sampson | last post by:
ey all, I'm in the process of creating a method of tracking whenever an objects properties are changed. Since its not possible to alter existing types I decided to used a proxy generated using...
5
by: WindAndWaves | last post by:
Greetings once more, I was wondering if someone figured out the difference between attributes and properties. I noticed that things like fields have a number of properties, but also...
12
by: Pol Bawin | last post by:
Hi All, Did somebody already define attributes for numerical properties to define value : minima, maxima, a number of decimal, ...? This information would be useful to unify syntax Polo
1
by: 2G | last post by:
Hi, I have a usercontrol with a custom propertie but in the designer, the properties doesn't expand it's properties so I can't change them. I've search google on this and came across things like...
3
by: Martin Montgomery | last post by:
I have, for example, a property called myProperty. I would like, when using a property grid to display the property name as "My Property". Is this possible. Is there an attribute etc Thank ...
2
by: Brian | last post by:
NOTE ALSO POSTED IN microsoft.public.dotnet.framework.aspnet.buildingcontrols I have solved most of my Server Control Collection property issues. I wrote an HTML page that describes all of the...
4
by: Thorsten Viel | last post by:
Hi, after searching and testing for hours, im off with that. Maybe you have a snippet or link for me. I have a class with properties. Some of the properties (not all) have a custom...
5
by: Jon Pope | last post by:
I've got a class which contains properties. I can supply this class to the Properties control, and it will properly display the properties and allow the user to edit them, etc. I would like to be...
17
by: David C. Ullrich | last post by:
Having a hard time phrasing this in the form of a question... The other day I saw a thread where someone asked about overrideable properties and nobody offered the advice that properties are...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.