Questions tagged [modelmetadata]
88 questions
0
votes
1 answer
StringLengthAttribute
I am using Asp.Net MVC 2, and trying to iterate through the metadata to add input controls to grid columns. Most attributes like DisplayAttribute, StringLength attribute, etc are not populated by the default modelmetadata provider.
1- I think these…

hazimdikenli
- 5,709
- 8
- 37
- 67
0
votes
1 answer
ASP.NET MVC2: Can you get ModelMetadata.ContainerType from within a collection?
I'm trying to call DisplayFor and DisplayForModel to iterate an IEnumerable<> with various element types from within a view. I have Templates defined for each element/Model type.
What I would like to do is check the…

Shaun Kohanowski
- 21
- 5
0
votes
1 answer
Extending CachedDataAnnotationsModelMetadataProvider to not cache some DataAnnotations
I'm trying to extend CachedDataAnnotationsModelMetadataProvider to not cache Custom ValidationAttribute.
How can i achieve this? I tried looking in aspnetwebstack, but it is too complicated to get answer; what do i need to override, as protected…

Igoris Azanovas
- 1,640
- 1
- 22
- 37
0
votes
2 answers
Limit JavaScript and CSS files on ASP.NET MVC 2 Master Page based on Model and View content
I want to include certain .js and .css files only on pages that need them.
For example, my EditorTemplate DateTime.ascx needs files anytimec.js and anytimec.css.
That template is applied whenever I use either the EditorFor or EditorForModel helper…

Zack Peterson
- 56,055
- 78
- 209
- 280
0
votes
1 answer
Localized ModelMetadata and Caching
I'm having problems with my localized Model attributes as we decided to not use the build-in localization functionallity.
public class LocalizedRequiredAttribute : RequiredAttribute
{
public LocalizedRequiredAttribute(string displayName)
…

Sebastian Jonas
- 21
- 1
0
votes
1 answer
.NET Custom Strongly Typed HTML Helper with deep property navigation
I've searched all around, read all the posts related to creating a strongly typed helper, but none have addressed my issue. Problem:
When referencing a simple property, all works well:
@Html.TextBoxGroupFor(x => x.BadgeNumber)
When trying to access…

Jack
- 9,156
- 4
- 50
- 75
0
votes
0 answers
Modelmetadata is populated for outer model, but not inner model,
I need reading material on how modelmetadata is populated and when the OnMetadataCreated method is called in the framework. When I created a viewmodel that contains a nested viewmodel, OnMetadataCreated was not called for the properties of the inner…

John Doe
- 69
- 3
- 9
0
votes
0 answers
How can I break up Lambda expression into the objects that make up the expression?
Given an expression such as:
m => m.Employee.Address.Line1
I need to create a function that can walk the expression, pulling out the objects involved, or AT LEAST the final object in the chain (i.e. the Address object above). So for the example…

Frank
- 1
- 1
0
votes
0 answers
MVC 3, ModelMetadata weird behavior during navigation
One of the properties in my model is decorated with Hide attribute. When I load a page this property is not displayed (as expected). When I click "Back" and then "Forward" buttons, essentially navigating away and then back, then this property shows.…

user981375
- 639
- 1
- 5
- 15
0
votes
2 answers
How to override Entity Framework validation error messages
I have an Entity Framework 4.1 model that supports multiple ASP.NET MVC web applications. I use DataAnnotations to define and localize label text and validation rules and error messages.
For some applications, I need the label text for certain…

Paul Taylor
- 5,651
- 5
- 44
- 68
0
votes
2 answers
Validation Application Block - How to use validation metada class
I'm using VAB to validate some classes with attributes and I'm using a metadata class to share the same validation among different classes.
When i try to validate an object in the controller (btw i'm using asp.net mvc) the ValidationResults does not…

JPP
- 360
- 6
- 22
0
votes
1 answer
Apply model metadata on complex objects
I have the following scenario
public class Foo {
public Bar FooBar { get; set; }
}
public class Bar {
[DisplayFormatAttribute(ApplyFormatInEditMode = true, DataFormatString = "{0:d}")]
public DateTime BirthDay { get; set; }
}
Now when…

marcus
- 9,616
- 9
- 58
- 108
-1
votes
2 answers
ModelMetadata additional attributes is always empty
I am trying to access a model's metadata attributes to create a helper to automatically add HtmlAttributes based on DataAnnotations.
Problem is, the attributes are always empty.
I have 2 basic classes to try on an empty project:
namespace…

Erick
- 5,969
- 10
- 42
- 61