modelmetadata

Finding target of LinFu proxy object

This is pretty much a duplicate question but instead of using Castle Dynamic Proxy I'm using LinFu http://stackoverflow.com/questions/1415675/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 problem is from what I can tell that MVC's defau...

MetadataType and client validation in ASP.NET MVC 2

Inherited properties and MetadataType does not seem to work with client side validation in ASP.NET MVC 2. The validation of our MetadataTypes work as expected on the server but for some reason it does not generate the appropriate client scripts for it. Client side validation kicks in as expected for properties with the DataAnnotations a...

ASP.NET MVC / Linq-to-SQL classes: Can I get it to infer readable display names?

If I have a table Orders with fields CustomerID, OrderID and OrderDate, then the "Linq-to-SQL classes" generated class will be called Orders, with members called CustomerID, OrderID and OrderDate. So far so good. However, if I then do Html.LabelFor(m => m.OrderDate) then the generated text will be "OrderDate" instead of "Order Date". I...

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. ...

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 methods in a view for a model with a DateTime type value. My technique: I've put this c...

ASP.NET MVC Custom MetadataProvider

I'm building a custom MetadataProvider and I'd like to access the actuall model value in the CreateMetadata method. public class IcpMetadataProvider : AssociatedMetadataProvider { protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, Func<object> modelAccessor, Type modelType, strin...

ModelMetadata: ShowForEdit property not appearing to work.

Iv wrote an MetaDataProvider like the one below and am using it in conjunction with Editor templates. The DisplayName is working correctly, but for some reason the ShowForEdit value it not having any effect. Any ideas? public class MyModelMetadataProvider : DataAnnotationsModelMetadataProvider { protected override ModelMetadata ...

Solution to metadata.HideSurroundingHtml not working

I have written a custom DataAnnotationsModelMetadataProvider that sets HideSurroundingHtml dynamically. public class ContentDrivenModelMetadataProvider : DataAnnotationsModelMetadataProvider { protected override ModelMetadata CreateMetadata(IEnumerable<Attribute> attributes, Type containerType, ...

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 ViewData.ModelMetadata.ContainerType from within the Template so that Template can determine if it was called as part of a...

datamining metadata

I build a bunch of data mining models on training data that is located in different folders. For eg. for data in folder1 I build an SVM based model, for data in folder2 I build an naive bayes model. I have almost 100 such folders and each of the folders have different data ( read different attributes ). Is there a framework which enables...

Is there a way to instruct ASP.NET MVC about some class metadata other than putting the MetadataTypeAttribute directly on the class?

Here's a sample of how it works now: [MetadataType(typeof(PersonMetadata))] public class Person { public string Name { get; set; } public int Age { get; set; } } public class PersonMetadata { [Required] public string Name { get; set; } [Range(0,150] public int Age { get; set; } } However I don't want the Metad...

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 etc) and I would like to reuse this information with different presentation layers later ...

Are MVC2 display templates considered good practice?

I'm learning the ASP MVC2 framework, with no prior knowledge of MVC1. At the moment I'm constructing a toy website for learning purposes. So far I've been primarily using Html.RenderPartial as my main means of organizing view rendering. In theory I'd prefer something less imperative and more declarative. I've read several tutorials on ...

expression.Compile() vs ModelMetadata.FromLambdaExpression

Hi folks! There is a common issue to write strongly-typed Html helpers. The problem is how to retrieve property name/value pair. Assume we have following Html helper declaration: public static string DatePickerFor<TModel>(this HtmlHelper<TModel> helper, Expression<Func<TModel, DateTime?>> expression) There are several solutions I fou...