Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

MVC3: What does the UIHint attribute do?

Posted on 2012-09-20
3
Medium Priority
?
736 Views
Last Modified: 2012-09-21
What does this attribute do in an MVC3 app?

       [UIHint("ProductViewModel"), Required]
0
Comment
Question by:newbieweb
3 Comments
 
LVL 38

Accepted Solution

by:
PaulHews earned 1200 total points
ID: 38420589
UIHint specifies a template for editor or display for the field.  In this example, assuming Product is the name of the field, when you call

@Html.EditorFor(model => model.Product)

it will pick up the template from the appropriate EditorTemplates folder.  Same for DisplayFor method.  

There's a good explanation here:

http://blogs.msdn.com/b/nunos/archive/2010/02/08/quick-tips-about-asp-net-mvc-ui-helpers-and-templates.aspx
0
 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 800 total points
ID: 38421544
The interesting thing that I have learned about display templates, and the default behavior, is if you have a view model class, and a display template with the same name, the template will be used.  This "magic" configuration can be confusing when troubleshooting an issue.  I am starting to think that explicitly specifying a template, gives you a "hint" to the display template, so that you know which one is giving you trouble.
0
 

Author Closing Comment

by:newbieweb
ID: 38421686
Thanks!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question