Questions tagged [modelmetadata]

88 questions
5
votes
1 answer

Get Types using IEnumerable GetGenericArguments

I have developed a MVC helper for generating display and editable tables (a jquery plugin is required to allow dynamic addition and deletion of rows with full postback in the editable tables) e.g. @Htm.TableDisplayFor(m => m.MyCollection as…
user3559349
5
votes
1 answer

How to Transfer DataAnnotation metadata to ViewModel with AutoMapper with Betty's Approach

I need clarification on how to implement Betty's code solution to transferring data annotation metadata to ViewModels with AutoMapper (see here). Or if you have a better way, please share that. Maybe the implementation of Betty's answer is obvious…
4
votes
2 answers

How can I provide my own ICustomTypeDescriptor in ASP.NET MVC?

I'm working on a small library for for ASP.NET MVC 3 that should offer better reusability of model metadata and easy mapping from data entities from / to custom viewmodels. For this I need to be able to provide my own implementation of…
Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
4
votes
2 answers

MVC3/4 Security & Model Binding for a dynamic object

I really need a second set of eyes on this so I'm hoping some of you can give me some feedback, I think I've been staring at it too long. I'm trying to setup a website using ASP.NET MVC3, and in this site I need the flexibility of creating dynamic…
4
votes
2 answers

ASP.NET MVC3 WebGrid Helper and Model Metadata

I'm trying to use the WebGrid html helper in ASP.NET MVC 3 to autogenerate the columns according to the information found in the ModelMetadata. For example the code in a view that accepts a list of objects would be: var grid = new…
kkara
  • 811
  • 1
  • 10
  • 11
4
votes
1 answer

ASP.NET MVC Custom ModelMetadataProvider and ModelValidatorProvider

In my ASP.NET MVC application, I have metadata based model defined in database. I have a custom object defining the metadata of the data and uses dataset for DTO. To display this, I am planning to write a custom ModelMetadataProvider and…
Avinash Tiwari
  • 135
  • 1
  • 10
4
votes
1 answer

Asp.Net MVC ModedMetadata question for HiddenInput

I have a very simple view-model in a dll that I want to keep separated from the main web mvc project. I am decorating the model with metadata attributes that will help the ui display the correct presentation (DisplayName, UIHint, DataType, ReadOnly…
Ronnie
  • 4,959
  • 10
  • 51
  • 69
4
votes
1 answer

Get the column name from the database in entity framework 6 database first with different property name in mapping

I am into a situation that my table names are different from the class property on the model using mapping in EF 6. the Model and Database goes like this: public class AGENTMap : EntityTypeConfiguration { public AGENTMap() { …
ECie
  • 1,265
  • 4
  • 21
  • 50
4
votes
1 answer

Add new Property to MVC ModelMetadata

I'm seeing alternative approaches to this such as AdditionalValues, but I'm wondering if it's possible to end up in a scenario where you can add a new property to the ModelMetadata object available in template views. For example you could have:…
Jacques
  • 6,936
  • 8
  • 43
  • 102
4
votes
1 answer

How can I extend CachedDataAnnotationsModelMetadataProvider?

We are looking to use CachedDataAnnotationsModelMetadataProvider as it improves performance and we use a lot of Meta Data in our MVC4 application. We are currently creating a custom ModelMetadataProvider inheriting from…
GraemeMiller
  • 11,973
  • 8
  • 57
  • 111
4
votes
1 answer

How do I get the fully qualified member name in an EditorTemplate?

I have an ASP.NET MVC 4 site and I am passing a nested property to an EditorTemplate and building the field name using ViewData.ModelMetadata.PropertyName however, this gets the property name of the child property, not the full dot-notation name of…
Greg B
  • 14,597
  • 18
  • 87
  • 141
3
votes
1 answer

how to use DataAnnotations in desktop application

When we are using EF (f.e.) via MVC, we can use ModelState.IsValid to detect a model can pass DataAnnotations metadata or not. But how can I use DataAnnotations metadata in a desktop (win-forms / wpf) application? More: In fact, I want to create an…
amiry jd
  • 27,021
  • 30
  • 116
  • 215
3
votes
1 answer

Reach out to ModelMetadata of one of model property

I was reading one of Brad Wilson's articles: ASP.NET MVC 2 Templates, Part 2: ModelMetadata http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-2-modelmetadata.html Let's assume that on my ASP.NET MVC 3 App, I have the following…
tugberk
  • 57,477
  • 67
  • 243
  • 335
3
votes
1 answer

asp.net mvc 3 Html.GetUnobtrusiveValidationAttributes and nested models

Here is the situation. I have some ViewModels that contain nested complex model types. Here is a snippet of one of the models (this is not a complete class): /// /// Defines the overall view when viewing contact details. ///…
user514005
3
votes
1 answer

MVC 3 - Accessing ModelMetaData for IEnumerable Model?

I'm trying to access the ModelMetaData for a Custom HtmlHelper that I'm working on. The HtmlHelper has a signature like so ... public static MvcHtmlString DataGrid(this HtmlHelper htmlHelper){} The (Razor) View looks like this ... @model…
Click Ahead
  • 2,782
  • 6
  • 35
  • 60