displayfor

ASP.NET MVC. How use DisplayNameFor in order to create a table heading and body?

半腔热情 提交于 2019-12-21 12:37:17
问题 How get a property display name using DisplayNameFor() to build a table header. for instance: @model IEnumerable<Item> <table class="table"> <thead> <tr> <td>@Html.DisplayNameFor(? => ?.prop1)</td> <td>@Html.DisplayNameFor(? => ?.prop2)</td> <td>@Html.DisplayNameFor(? => ?.prop3)</td> </tr> </thead> <tbody> @foreach (Item item in Model) { <tr> <td>@Html.DisplayFor(i => item.prop1)</td> <td>@Html.DisplayFor(i => item.prop2)</td> <td>@Html.DisplayFor(i => item.prop3)</td> </tr> } </tbody> <

replace character in text generated by html.displayfor(function

我的梦境 提交于 2019-12-12 14:35:35
问题 A webpage currently gives a device ID with hyphens in the number, I want to replace - with : instead (that is to say, replace any hyphens with a colon), but only at display time. I'm pretty confident this is line that is generating the device ID shown on the page: @Html.DisplayFor(Function(m) m.DeviceID)</span> <br /> Is it possible to change this output to include colons instead? 回答1: You can create a display template. Create the following partial view ~/Views/Shared/DisplayTemplates/

ASP.NET MVC. How use DisplayNameFor in order to create a table heading and body?

别等时光非礼了梦想. 提交于 2019-12-04 07:18:35
How get a property display name using DisplayNameFor() to build a table header. for instance: @model IEnumerable<Item> <table class="table"> <thead> <tr> <td>@Html.DisplayNameFor(? => ?.prop1)</td> <td>@Html.DisplayNameFor(? => ?.prop2)</td> <td>@Html.DisplayNameFor(? => ?.prop3)</td> </tr> </thead> <tbody> @foreach (Item item in Model) { <tr> <td>@Html.DisplayFor(i => item.prop1)</td> <td>@Html.DisplayFor(i => item.prop2)</td> <td>@Html.DisplayFor(i => item.prop3)</td> </tr> } </tbody> </table> what should I write in the question marks? DisplayNameFor() has an overload that accepts