Thursday, 12 October 2017

MVC Create custom Display templates

Step 1: Add DisplayTemplates named folder in Views > Shared.

Step 2:- Create template that you want to render like below:-

Views > Shared > DisplayTemplates  > ToolTip.cshtml
<div class="tooltip-block animation">
<span class="right-arrow"></span>
<div class="tooltip-pads">
    <img alt="" src="@Url.Image("tooltip-icon.jpg")" />
    <p>@ViewBag.TooltipText</p>
</div> <!-- tooltip-pads -->
</div> <!-- tooltip-block -->

Step 3:- Now use it in view as bellow:-

In .cshtml View :-



@Html.Display("", "ToolTip", new { TooltipText = "This is the total number of estimate pledgers for the duration of the Campaign." })

No comments:

Post a Comment