Validating the presence of a property

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

Is there a way, in code, to find out if a control in .NET has a property before accessing it? Not only that, but its base class too

I'd like to do something like

if (mycontrol.BaseClass == "textfield" && PropertyExists(mycontrol, "MyProperty")) mycontrol.MyProperty = someValue

Thanks

Skip.
 
Skip said:
Is there a way, in code, to find out if a control
in .NET has a property before accessing it?
Not only that, but its base class too?

Have a look at the System.Reflection namespace. This allows you to get
meta-information about types at run time.

If you are checking for properties then I think the GetFields method is what
you want.

P.
 
Paul E Collins said:
Have a look at the System.Reflection namespace. This allows you to get
meta-information about types at run time.

If you are checking for properties then I think the GetFields method is
what
you want.

Type.GetProperties() actually.
 
Back
Top