Get Server Property Names Programatically?

  • Thread starter Thread starter clintonG
  • Start date Start date
C

clintonG

Somebody help me learn which class and methods may be used to get the names
of all properties for a given server control? Thank you...
 
clintonG said:
Somebody help me learn which class and methods may be used to get the names
of all properties for a given server control? Thank you...

Clinton,

The classes you should look at are in the System.Reflection namespace. Usually,
you'll start out by calling GetType( ) on an object (it can be any object, it doesn't
need to be a server Control) and from a Type object you can query all sorts of
CLR metadata on that type such as it's properties.

using System.Reflection;
// . . .
PropertyInfo[ ] props = serverControl1.GetType( ).GetProperties( );

Gets you all of the public instance properties on the serverControl1's Type as
an array of PropertyInfo objects (which have properties like Name and
PropertyType that describe the nature of the property).


Derek Harmon
 
Thanks Derek. I was using the Object browser and wondering how to read
properties in code as I think that's going to be the most expedient
methodology for those interested in generating ASP.NET 2.0 .skin files for
any given theme.

<%= Clinton Gallagher

Derek Harmon said:
Somebody help me learn which class and methods may be used to get the names
of all properties for a given server control? Thank you...

Clinton,

The classes you should look at are in the System.Reflection namespace. Usually,
you'll start out by calling GetType( ) on an object (it can be any object, it doesn't
need to be a server Control) and from a Type object you can query all sorts of
CLR metadata on that type such as it's properties.

using System.Reflection;
// . . .
PropertyInfo[ ] props = serverControl1.GetType( ).GetProperties( );

Gets you all of the public instance properties on the serverControl1's Type as
an array of PropertyInfo objects (which have properties like Name and
PropertyType that describe the nature of the property).


Derek Harmon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top