Question

Is there a list of all the UIHints that you can call in MVC 3?

I checked Google and searched on here, but was unable to find a list. Any help is appreciated.

---------------------------------------------------------------EDIT-------------------------------------------------------------- I apologize, I ended up finding the answer out.. I should have phrased the question as what are the datatypes that you can use as a UI Hint.. I am aware that you can create your own, but there were also a set of options that were already available. It is an enumeration of options apparently that is defined in using System.ComponentModel.DataAnnotations. Thank you for your responses though.

Was it helpful?

Solution

The UI Hint will simply help determine the editor template to use when using DisplayFor and EditorFor to request either templated display or a form editor for a view model property. Normally the editor template with the name matching the type name of the property will be used, but if you have created a custom editor for the property then the UI Hint tells the MVC runtime to use that instead.

On that basis your question doesn't make a lot of sense as there can be no list, the editors I create to satisfy the requirements of projects I work on will be different to those in your projects. As with so much of the MVC framework, it operates by convention - the framework will expect to find your name templates in "~/Views/Shared/DisplayTemplates" and "~/Views/Shared/EditorTemplates" respectively.

If you want to know the UI hints you can use in your project then simply look at the available templates (matched by name) in these directories.

The UI Hint is useful where the primitive type you are using to represent or store your data does not fully reflect the restrictions or business logic of that data - for example you might store hours of the day in a numeric type, but of course the valid data for this property is only a subset of the valid data for the integer type (1-24 versus 1 - 2,147,483,647). Specifying a custom editor using UI Hint allows you to create a editor that provides sensible inline validation, helping your users use the application. In this case you might use a drop down list or HTML number input with min and max values.

See http://www.devcurry.com/2013/04/custom-templates-in-aspnet-mvc.html for more on UI hint.

OTHER TIPS

You appear to misunderstand what the purpose of the UIHint is for. There is no "list" of UIHints because these are strings that you create yourself in order to tell MVC which template you wish to use from the templates you have created.

In other words, UIHint is entirely user (that is, you the developer) defined. It would be like asking for a list of variable names that are possible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top