Reputation: 149
I Have a model MyModel
public class MyModel { [UIHint("Str")] public string Name {get;set;} }
In the View, I am rendering model using
@Html.DisplayForModel("SomeTemplate")
So, the model is using SomeTemplate as it DisplayTemplate.
So the UIHint is not being rendered in the SomeTemplate.
Is there any solution to render the UIHint in another DisplayTemplate or is it not possible at all,
Upvotes: 0
Views: 853
Reputation: 1505
You have some inconsistancies in your code.
First, UIHint is used to define the name of the display template to render the given property, and not to add a string in the rendered output.
Second, the parameter for DisplayForModel is not the name of the display template (it is selected automatically based on convention by the name of the model, or defined using UIHint)
So what you could do is: Assuming your model class is named MyClass
Create a display template named MyClass.cshtml under you DisplayTemplates Folder
add the "Str" inside the template
call DisplayForModel without parameter (given that the model in the current view is the same MyClass)
if i have misunderstood something please point it out
Upvotes: 1