0

I have gone through a couple of articles regarding UIHint attribute in mvc but none of them specifies clearly what it is or advantages of using it and also how to implement it in code.

Thanks!

Sonu K
  • 2,562
  • 2
  • 20
  • 32
  • possible duplicate of [UIHint Attribute in MVC](http://stackoverflow.com/questions/8069994/uihint-attribute-in-mvc) – ataravati May 19 '15 at 12:00
  • But that post doesn't give enough information on this. Any additional information on how to implement SomeTemplate.ascx as mentioned in the post would help me a lot. – Sonu K May 19 '15 at 12:04
  • SomeTemplate.ascx or SomeTemplate.cshtml is just a partial view. What kind of information do you need? – ataravati May 19 '15 at 12:05
  • Sorry for confusion, But I just wanted to know what should be there in that partial view. – Sonu K May 19 '15 at 12:07
  • 1
    Well, it depends what your property is. Let's say you want to implement an editor template for a DateTime property using jQuery UI. You can put a jQuery UI DatePicker in the template (SomeTemplate.cshtml). – ataravati May 19 '15 at 12:11

1 Answers1

1

The benefit of "UIHint" attribute is that it allows you to selectively apply the template. Let's say that you create an editor template for bool. If you name it "bool" it will automatically apply on all bool fields. But if you name it "abc123" you have the luxury of calling it selectively by decorating the property in your model with the "UIHint" attribute and only having it replace the default handlers as you desire.

It is easiest to understand that all types have a default handler so when you're using "TextboxFor", that too is applying a template, it just happens to be a native one as opposed to a custom template of your choosing.

New2ASPMVC
  • 102
  • 1
  • 11