Questions tagged [display-templates]

Display template is a html template which can be repeat for each item in its model and it will load in specific section of a view of asp.net web application. A template can have styles/scripts or Razor codes in itself also.

102 questions
0
votes
1 answer

Define a DisplayTemplate for a Custom Type

Is it possible to specify the Display Template name when defining a property Type? For example, I have some classes: public interface IFoo {} public class Foo : IFoo {} public class Bar : IFoo {} Then I have a Model: public class MyModel{ IFoo…
Philip Pittle
  • 11,821
  • 8
  • 59
  • 123
0
votes
2 answers

MVC DisplayTemplate - change output for a given string value

I currently have a view rendering a display page for a list of Employee entities. The values returned from the database for the Gender property are a string value of "M" or "F" for the corresponding gender. I would like to be able to show string…
James P
  • 2,201
  • 2
  • 20
  • 30
0
votes
1 answer

UIHint not working under model DisplayTemplate

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…
0
votes
1 answer

Displaying html-formatted text for enum values in MVC

I have an MVC 5 app that uses an existing system's values to display unit-related data. I'm utilizing data annotations to convert the nasty-looking legacy data to nicely-formatted versions on the UI. I'm trying to figure out how to display the M3…
0
votes
2 answers

DisplayTemplate being ignored (covarient interface?)

This is a weird one. I have the following view file (Views/Search/Submit.cshtml): @model IEnumerable> @foreach (var provider in Model) { var results = provider.Value.Results.Take(10); if…
Isaac
  • 1,677
  • 3
  • 15
  • 22
0
votes
1 answer

ASP.Net: Html.Display()-Method ignores templatename

I have the following method returning html-code for a model according to the PropertyInfo referencing TDatas property. public MvcHtmlString GetHtml(HtmlHelper helper) { if (PropertyInfo.IsDefined(typeof(UIHintAttribute), true)) { …
Tobias
  • 2,945
  • 5
  • 41
  • 59
0
votes
2 answers

MVC Html.DisplayModelFor Expects IEnumerable, which I think I'm passing, but I get error

I am trying to use a display template (Pet.cshtml), which I have placed in ~/Views/Shared/DisplayTemplates, as per convention. The Index action gets the IEnumerable and passes it to Index.cshtml, which passes it along to _PetTablePartial. So far,…
Scott
  • 2,456
  • 3
  • 32
  • 54
0
votes
0 answers

How do I use a DisplayTemplate instead of a PartialView?

I have created a SumFor extension method on HtmlHelper. The purpose is to take a property from a model and calculate the sum of all values and return it. This works, but the value is returned as a plain string. Eg: 130.50 I often use custom…
0
votes
1 answer

replacing DisplayTemplate with knockout binding

I'm currently using a DisplayTemplate to show a property of my Model: @Html.DisplayFor( m => m.TheProperty, "myTemplate") The template output the html for an image, which source depends on whether the Model (TheProperty) is null or not. Now, I'm…
Sam
  • 13,934
  • 26
  • 108
  • 194
0
votes
1 answer

MVC3 Display Templates Truncate String

I have created a custom Display For template that will be used mainly in my index file so that when the records are shown in the lists, they are not turned into ugly looking creature if some records are way too lengthy. I have tried…
Sorrel Vesper
  • 414
  • 4
  • 18
0
votes
1 answer

Display Template For Generics - View is not found

I have the following classes: public class Widget { public string Name { get; set; } } GenericModel public class GenericModel { public List Data { get; set; } } My Controller action is: public ActionResult Simple() { …
ek_ny
  • 10,153
  • 6
  • 47
  • 60
-1
votes
1 answer

How to configure an MVC dropdown depending on which view calls it

I have two views, BatchReceipt and Receipt which utilise the same model. Until now they have used the same display template of ReceiptType. But I want to have one exclude certain items and the other to have the full list (so essentially a second…
Marc L
  • 837
  • 9
  • 19
  • 40
1 2 3 4 5 6
7