Questions tagged [modelmetadata]
88 questions
2
votes
1 answer
Do model metadata providers in ASP.NET MVC 3 support dynamic metadata?
I'm trying to implement some custom model metadata in ASP.NET MVC 3. I can't use data annotation attributes since some of the metadata could change based on configured values, so I need a solution that will let me set the metadata on every request.…

Dave A
- 484
- 3
- 10
1
vote
1 answer
ability to change the ModelMetadataProviders.Current in areas
I have a special case where I would need the ability to use multiple ModelMetadaProviders in an application. Certain area would use a specific provider, another area will use some other. I mainly need this because each of those providers uses…

mare
- 13,033
- 24
- 102
- 191
1
vote
1 answer
Is there any out of the box code to serialize a model to Key Value Pairs using ModelMetaData?
I know that ModelMetadata is used to bind values from a model to fields. Is there any out of the box MVC code that will take a model and use it's ModelMetadata to generate KeyValuePairs for the values of all of it's properties?

Oved D
- 7,132
- 10
- 47
- 69
1
vote
1 answer
Change field in model metadata to read only in runtime based on criteria
I'm creating a generic interface for editing pages and on some pages eg the start page I need to disable or remove some fields. The form is rendered with Html.EditorFor. What is the best way of doing this?

marcus
- 9,616
- 9
- 58
- 108
1
vote
3 answers
RedBean PHP: Is there a way to protect a database column from being changed? (ex: insertion_date )
Already used as many ORMs as you can imagine. At moment I'm in a love / hate crush with RedBean PHP. Here we go... after a few hours studying it I got a doubt about whats the better way to solve this very basic problem (best way means, in this case,…

marcio
- 10,002
- 11
- 54
- 83
1
vote
1 answer
Html.LabelFor does not use Name from DisplayAttribute
I have a model like this
[MetadataType(typeof(PageMetadataMetadata))]
public class PageMetadata : IPageMetadata {
public virtual string Name { get; set; }
}
and my metadata class like this
internal class PageMetadataMetadata {
[Display(Name…

marcus
- 9,616
- 9
- 58
- 108
1
vote
1 answer
Inconsistent behavior in HtmlHelper methods retrieving model metadata
I’m tracing down an unexpected behavior in MVC3, having to do with how it gets model metadata.
I had previously talked to one of my developers about using the same EditorTemplate for some data which is collected in two different areas of the system.…

Mark Shapiro
- 1,192
- 10
- 13
1
vote
1 answer
How can I get AdditionMetadata attribute from the controller?
In some class, let say Class A, I have a property (of type B):
public class A {
...
[AdditionalMetadata("foo", "bar")]
public B attr {get; set;}
...
}
Later on, in my controller, I instantiate this class and make it a model:
...
A obj = new…

igorludi
- 1,519
- 2
- 18
- 31
1
vote
1 answer
Modify DataType attribute dynamically in ASP.NET MVC
I have a ViewModel containing this property:
[Display(Name = "Email")]
[DataType(DataType.EmailAddress)]
[DisplayFormat(NullDisplayText = "Unavailable")]
public string Email { get; set; }
Is there a way to set the DataType…

Wadjey
- 145
- 13
1
vote
0 answers
Customize ModelMetadata with CreateMetadata
The first time a user chooses a value from a select list, we show a default option with the text Pick one and value -1.
To help with this we have a custom attribute NotEqualAttribute. When a drop-down list is required we have to use both attributes…

Razcer
- 394
- 4
- 17
1
vote
1 answer
ASP.NET MVC 3 Data Attributes - Programmatically Set UIHint from Controller
If i have a ViewModel like this:
public class SignupViewModel
{
[Required]
[DisplayName("Email:")]
public string EmailAddress { get; set; }
}
And use EditorFor to render out the form fields:
@Html.EditorFor(model => model.EmailAddress…

RPM1984
- 72,246
- 58
- 225
- 350
1
vote
1 answer
Source Code for DataAnnotationsModelMetadataProvider
For some reason, .NET Reflector throws an exception when I try to reflect on this class. It works for everything else.
What is the source code of DataAnnotationsModelMetadataProvider, please?

smartcaveman
- 41,281
- 29
- 127
- 212
1
vote
1 answer
Solution to metadata.HideSurroundingHtml not working
I have written a custom DataAnnotationsModelMetadataProvider that sets HideSurroundingHtml dynamically.
public class ContentDrivenModelMetadataProvider : DataAnnotationsModelMetadataProvider
{
protected override ModelMetadata…

Dan
- 29,100
- 43
- 148
- 207
1
vote
1 answer
How do I populate the Watermark property on ModelMetaData?
I've just finished reading http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-2-modelmetadata.html In the article Brad lists the Watermark property but there is no mention of which DataAnnotation is used to populate it.

Kirschstein
- 14,570
- 14
- 61
- 79
1
vote
2 answers
Finding target of LinFu proxy object
This is pretty much a duplicate question but instead of using Castle Dynamic Proxy I'm using LinFu Getting underlying type of a proxy object
I'm using automapper to create proxies of interfaces that I'm sending to my viewmodel in Asp.net MVC. My…

John Farrell
- 24,673
- 10
- 77
- 110