display-templates

How to make display template in MVC 4 project

两盒软妹~` 提交于 2019-12-10 15:22:29
问题 Hi i'm building application in MVC and i want to use a display template to display my model in a view. This is my template, but it gives me error when I try to display it: @*<tr> <td>@Html.Display(NameE)</td> <td>@Html.Display(NameC)</td> <td>@Html.Display(NameR)</td> <td>@Html.Display(Timespan) </td> <td><button class="button" type="submit" name="Review"></button></td> </tr>*@ I want this template to display each row filled with database data in the td 's, but it is doing nothing. What am I

ASP.NET MVC 3 Custom Display Template With UIHint - For Loop Required?

断了今生、忘了曾经 提交于 2019-12-09 06:07:39
问题 If i have a ViewModel like this: public class MyViewModel { [UIHint("SomeTemplate")] public ICollection<SomeViewModel> Submodel { get; set; } } And a strongly-typed View with a line of HTML like this: @Html.DisplayFor(model => model.Submodel) And a display template with a signature like this: @model MvcApplication1.Models.SomeViewModel I get an error saying "the model item is of type List<SomeViewModel> but this dictionary requires a model of type SomeViewModel .". Which makes sense, but i

ASP.NET MVC 3: Output specific view for concrete implementation

一世执手 提交于 2019-12-06 11:07:45
问题 I have an IEnumerable of a base type as my model. I need to display a different bit of HTML in a list depending on what the concrete type is. So the resulting list might look similar to this in HTML: <ul> <li class="points">Points - Item 1 - 10 points <a href="#">Remove</a></li> <li class="media">Media - Item 2 - your_uploaded_image.jpg <a href="#">Remove</a></li> <li class="content">Content - Item 3 <a href="#">Remove</a></li> </ul> It's likely I will add another type to this later so

ASP.NET MVC Display Template for strings is used for integers

不问归期 提交于 2019-12-04 22:52:45
问题 I recently hit an issue with ASP.NET MVC display templates. Say this is my model: public class Model { public int ID { get; set; } public string Name { get; set; } } this is the controller: public class HomeController : Controller { public ActionResult Index() { return View(new Model()); } } and this is my view: <%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<DisplayTemplateWoes.Models.Model>" %> <!DOCTYPE html> <html> <head runat="server"> <title>Index</title> </head> <body> <div> <

ASP.NET MVC 3: Output specific view for concrete implementation

余生长醉 提交于 2019-12-04 16:56:08
I have an IEnumerable of a base type as my model. I need to display a different bit of HTML in a list depending on what the concrete type is. So the resulting list might look similar to this in HTML: <ul> <li class="points">Points - Item 1 - 10 points <a href="#">Remove</a></li> <li class="media">Media - Item 2 - your_uploaded_image.jpg <a href="#">Remove</a></li> <li class="content">Content - Item 3 <a href="#">Remove</a></li> </ul> It's likely I will add another type to this later so solutions like the following aren't really what I'm after. @foreach(var item in Model) { if(item is PointImpl

MVC Razor display template

放肆的年华 提交于 2019-12-04 15:30:44
I have a list of items that I am passing to a view. I would like to render each item using a display template. However, something is wrong, as I don't get the field properly rendered. Here is my main view (Index.cshtml): @model IEnumerable<CustomEntity> @{ ViewBag.Title = "Index"; } @Html.DisplayFor(m=>m) Here is my display template: @model CustomEntity <div> @Html.LabelFor(m=>m.Name): <strong>@Model.Name</strong> @Html.LabelFor(m=>m.Icon): <strong>@Model.Icon</strong> @Html.LabelFor(m=>m.TypeName): <strong>@Model.TypeName</strong> </div> The page loads, but doesn't display the values of the

Freemarker does not assign staticUtil

不羁岁月 提交于 2019-12-04 04:13:42
I worked Application Display Templates on liferay 6.2, I use freemarker help pagination the dynamics data list of liferay. When I upgrade to liferay 7, it is a problem. Liferay 7 use code <#assign records = ddlDisplayTemplateHelper.getRecords(reserved_record_set_id)> for get a records. Old code: <#assign DDLRecordLocalService = serviceLocator.findService("com.liferay.portlet.dynamicdatalists.service.DDLRecordLocalService")> <#assign records = DDLRecordLocalService.getRecords(reserved_record_set_id)> <#assign totalRecord = DDLRecordLocalService.getRecordsCount(reserved_record_set_id, 0) > It

MVC 3 multiple DisplayFor-Templates

蹲街弑〆低调 提交于 2019-12-03 16:16:53
问题 I'm trying to make a custom template for a basket item list. I need a few different templates, as I have different ways of displaying the item, depending on if it's on the webpage or in a mail. Now my problem is, that when I use the default name it works flawlessly. @Html.DisplayFor(b => b.Items) But when I try to add a template name, I get an expection that my templates needs to be of a list type IEnumerable and not BasketItem. @Html.DisplayFor(i => basket.Items, "CustomerItemBaseList") Any

ASP.NET MVC 3 Generic DisplayTemplates

十年热恋 提交于 2019-12-01 17:30:41
I've just started a project using ASP.NET MVC 3. I'm building on top of an existing object system, so one of the first things I have to do is define display and editor templates for the various types that exist. Is it possible in MVC to define a DisplayTemplate with a generic argument? For example, we have a BitString<T> class which takes an enumeration as the generic argument and represents a list of options wrapping the supplied enumeration. I'm hoping I can define a single Display/Editor template that handles all BitString instances. I'm currently using Razor for my views, but I don't mind

How do I override DisplayFor boolean?

谁都会走 提交于 2019-11-30 11:02:17
How do i create a display template so i can display a bool as Yes or No not a checkbox? Using mvc3 <%: Html.DisplayFor(model => model.SomeBoolean)%> I had to create something similar so it would display "Sim" and "Não" (portuguese Yes/No). I created the following file: Views\Shared\DisplayTemplates\Boolean.ascx And added the following code: <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %> <%= (bool) ViewData.Model ? "Sim" : "Não" %> Hope this helps! EDIT Forgot, in your view, simply call it like so: <%= Html.DisplayFor(i => item.Ativo) %> EDIT 2 For a nullable