PC Review


Reply
Thread Tools Rate Thread

.ASP Properties vs Attributes

 
 
Patrick *
Guest
Posts: n/a
 
      30th Dec 2004
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.






 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=
Guest
Posts: n/a
 
      30th Dec 2004
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/
private.php?do=newpm&u=
PGP KeyID: 0x0270466B
 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      30th Dec 2004
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='private.php?do=newpm&u=?subject=Cor 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 *" <(E-Mail Removed)>

> 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.
>
>
>
>
>
>



 
Reply With Quote
 
Zach
Guest
Posts: n/a
 
      30th Dec 2004

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...

Hey guys, these explanations, however valuable are no definitions.


 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      30th Dec 2004
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" <(E-Mail Removed)>> Hey guys, these explanations, however valuable are no definitions.>>

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      30th Dec 2004
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

 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      30th Dec 2004
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


 
Reply With Quote
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      30th Dec 2004
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.
>
>
>
>
>
>
>

 
Reply With Quote
 
=?Utf-8?B?RGFsZQ==?=
Guest
Posts: n/a
 
      30th Dec 2004
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.
>
>
>
>
>
>
>


 
Reply With Quote
 
=?Utf-8?B?VGhvbWFzIFRheWxvcg==?=
Guest
Posts: n/a
 
      30th Dec 2004
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.
>
>
>
>
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Localizing attributes in properties =?Utf-8?B?U3RldmUgVGVlcGxlcw==?= Microsoft C# .NET 2 27th Apr 2005 08:45 PM
Attributes and Properties Chuck Bowling Microsoft C# .NET 6 25th Mar 2005 11:05 PM
Attributes of properties Joey Callisay Microsoft Dot NET Framework Forms 1 26th Aug 2004 11:22 AM
Folder attributes / properties Windows XP Basics 2 12th May 2004 12:15 PM
Once again, attributes for MC++ properties Edward Diener Microsoft VC .NET 4 1st Feb 2004 11:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:39 PM.