Patrick said:
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.