Remove attributes from subclass

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

I have written a descendant of CustomValidator, but I don't want it to have a
default value for ForeColor. Is there any way to remove the
DefaultValueAttribute from the descendant's ForeColor?
 
Barry,

Unfortunately, since the DefaultValue attribute is inherited, you can't
remove it from the metadata. However, you can place the DefaultValue
attribute on the derived class, and override what the default value should
be.

Hope this helps.
 
Nicholas said:
Unfortunately, since the DefaultValue attribute is inherited, you can't
remove it from the metadata. However, you can place the DefaultValue
attribute on the derived class, and override what the default value should
be.

It should be nothing, but recreating the parameter with null doesn't work.
I got around the problem by overriding ForeColor with set {return null;}, but
this is a rather blunt solution which doesn't solve the general problem.
 
Back
Top