What is the difference between attributes and properties in HTML/JAVASCRIPT ?

The difference is that,  the  prop  method deals with properties defined by the Dom  ApI  HTMLElement  object,  rather than attributes defined by the  htmL element in markup.

Often,  the attributes and properties are the same,  but this isn’t always the case.  A simple example is the  class  attribute,  which is represented in the  HTMLElement  object using the  className  property.

In general,  the  prop  method is the one you should use because it returns objects that are easier to work with than attribute values.

Programming is Easy !!!!

How to loop through object’s properties ?

If you are looking to loop through all properties of an object then this article may be helpful for you.

The .NET Framework provides two ways to access metadata on a type:

1) Reflection API provided in the System.Reflection namespace

2) TypeDescriptor class

Folowing is the sample code for TypeDescriptor class.

	public class EmployeeClass
        [Description("Gives/Store employee first name")]
        public string FirstName { get; set; }

        [Description("Gives/Store employee last name")]
        public string LastName { get; set; }

        [Description("Gives/Store employee gender info")]
        public string Gender { get; set; }

        [Description("Gives/Store employee age")]
        public int Age { get; set; }
    EmployeeClass objEmployee = new EmployeeClass()
		FirstName = "Jogendra",
		LastName = "Singh",
		Gender = "Male",
		Age = 28

	PropertyDescriptorCollection pdCollection = TypeDescriptor.GetProperties(objEmployee);

	foreach (PropertyDescriptor property in pdCollection)
		object propDisplayName = property.DisplayName;                
		object propDesc = property.Description;
		object propValue = property.GetValue(objEmployee);

For more info please visit to :-


Programming is Easy…