views:

51

answers:

2

I am looking to have an attribute "show" on certain properties in my class and give the user the option to show other properties in the view.

Can I change a custom attribute from the front end?

A: 

Hello,

Are you talking about the Filter attributes? If you are, you cannot change properties as they are statically defined, unless the code within the attribute happens to reference a static class or within the context at execution time, and then you pretty much can access within the attribute anything from that static or the context...

If I'm on the wrong track, please let me know.

HTH.

Brian
No, I'm talking about the custom attributes as seen here used for validation: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx
Sara Chipps
OK, works similarly though; data annotation validators define all the properties statically, but within the validator attribute definition, you can refer to static classes to make it dynamic that way...
Brian
A: 

I am not sure attributes are the best approach for dynamically attaching metadata. Normally attributes are attached at code generation time.

ktingle
I wouldn't say that reflection is slow (on modern hardware). It's pretty much a standard practice in ASP.NET MVC. Also I agree, this sounds like a model concern. You could have additional properties that dictate which properties should be rendered by the view.
Ryan