[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Setting the BrowsableAttribute at Runtime

Nathan Sokalski

7/25/2009 10:26:00 PM

I have a class that I am writing in which I want to set the
BrowsableAttribute of a Property inherited from it's base class at runtime.
How and where would I do this? Thanks.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansok...


2 Answers

Mark Hurd

7/26/2009 8:31:00 AM

0

"Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
news:u9ptgbXDKHA.3848@TK2MSFTNGP02.phx.gbl...
>I have a class that I am writing in which I want to set the
>BrowsableAttribute of a Property inherited from it's base class at
>runtime. How and where would I do this? Thanks.

If you're building the type at runtime, you need to call
PropertyBuilder.SetCustomAttribute with a CustomAttributeBuilder you've
created with the Attribute you want.

Otherwise you can't change a compiled type at runtime.

You may however be able to use ComponentModel.TypeDescriptionProvider to
fake what you want, depending upon where you need the functionality.
Don't have time to explain this further now...


--
Regards,
Mark Hurd, B.Sc.(Ma.) (Hons.)

Nathan Sokalski

7/26/2009 11:56:00 PM

0

That sounds pretty simple, but I also need to know which eventhandler to do
it in (Init? PreRender? Load?). Thank you for the help.
--
Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansok...

"Mark Hurd" <markhurd@ozemail.com.au> wrote in message
news:ugQ7otcDKHA.4064@TK2MSFTNGP04.phx.gbl...
> "Nathan Sokalski" <njsokalski@hotmail.com> wrote in message
> news:u9ptgbXDKHA.3848@TK2MSFTNGP02.phx.gbl...
>>I have a class that I am writing in which I want to set the
>>BrowsableAttribute of a Property inherited from it's base class at
>>runtime. How and where would I do this? Thanks.
>
> If you're building the type at runtime, you need to call
> PropertyBuilder.SetCustomAttribute with a CustomAttributeBuilder you've
> created with the Attribute you want.
>
> Otherwise you can't change a compiled type at runtime.
>
> You may however be able to use ComponentModel.TypeDescriptionProvider to
> fake what you want, depending upon where you need the functionality. Don't
> have time to explain this further now...
>
>
> --
> Regards,
> Mark Hurd, B.Sc.(Ma.) (Hons.)