razorengine

Cannot implicitly convert type system linq IQueryable to system collections generic List

混江龙づ霸主 提交于 2019-12-02 09:57:20
Unable to fetch Data from View Model Controller to View,i have properly checked the working of query in LINQpad. However I am missing the conversion of the output of query which can be displayable in View. I have three Data Models Products,Images,Specifications which i combined into ViewModel with only selected properties and want to displaythe same. public class ViewModelController : Controller { private OMSEntities db = new OMSEntities(); // GET: ViewModel public ActionResult Index() { var product = new Product(); var prices = new Price(); var orders = new Order();

Emitting an HTML string from anonymous type property in a repeated, dynamically-typed Partial View

对着背影说爱祢 提交于 2019-12-02 05:19:39
I am passing an anonymous type into a dynamic partial view as part of the @model , and one of the properties is a string that contains some HTML. When I use the HtmlHelper methods to render the property, the Razor engine is encoding the string, resulting in literal text on the page - <i>text</i> in this case, instead of the desired text . Since it is a dynamically typed View, I cannot call the property directly. Specifically, if I try to bind to @Model.MyField , I get a RuntimeBindingException : 'object' does not contain a definition for 'MyField' Ideally I could create a type (or at least an

RazorEngine @Html helpers work, but escape the Html

戏子无情 提交于 2019-12-02 02:12:36
问题 I am using RazorEngine to parse templates from html snippets on a web page. (This is a legacy system that switching to Mvc Razor views isn't possible, so we are switching small sections over to using RazorEngine where it makes sense). There are many of questions on SO and the internet trying to get Mvc's Html and Url helpers to work with Razor engine. To get @Html syntax to work, I've modified some code found here to add Html to the base template: public HtmlHelper<t> Html { get { if (helper

RazorEngine @Html helpers work, but escape the Html

人盡茶涼 提交于 2019-12-01 23:47:27
I am using RazorEngine to parse templates from html snippets on a web page. (This is a legacy system that switching to Mvc Razor views isn't possible, so we are switching small sections over to using RazorEngine where it makes sense). There are many of questions on SO and the internet trying to get Mvc's Html and Url helpers to work with Razor engine. To get @Html syntax to work, I've modified some code found here to add Html to the base template: public HtmlHelper<t> Html { get { if (helper == null) { var writer = this.CurrentWriter; //TemplateBase.CurrentWriter var vcontext = new ViewContext

The type or namespace 'Mvc' name does not exist in the namespace 'System.Web'

时光毁灭记忆、已成空白 提交于 2019-12-01 12:09:56
I have a class library that uses RazorEngine to generate emails. RazorEngine uses Mvc. I have referenced System.Web.Mvc in my library class, set it to copy local, and it is present in the Bin folder. However I still get this exception. The only way I got it working, is to actually call something from the Mvc namespace like MvcHtmlString test = new MvcHtmlString("test"); before calling RazorEngine (solution found here ) I guess it's not the end of the world, but I would still like to resolve this problem (or at least understand what's causing it). Cheers OK, so I was able to boil the problem

The type or namespace 'Mvc' name does not exist in the namespace 'System.Web'

喜夏-厌秋 提交于 2019-12-01 11:12:11
问题 I have a class library that uses RazorEngine to generate emails. RazorEngine uses Mvc. I have referenced System.Web.Mvc in my library class, set it to copy local, and it is present in the Bin folder. However I still get this exception. The only way I got it working, is to actually call something from the Mvc namespace like MvcHtmlString test = new MvcHtmlString("test"); before calling RazorEngine (solution found here) I guess it's not the end of the world, but I would still like to resolve

The property 'ID' is part of the object's key information and cannot be modified in asp.net mvc

痞子三分冷 提交于 2019-12-01 09:21:32
I have used entity framework with code first approach. when I am trying to pass record one by one Fromdate to Todate, 1st time its work, after it gives error like: "The property 'ID' is part of the object's key information and cannot be modified." var fd = todaycooked.CookDate; // 2016-07-01 var td = todaycooked.ToCookDate; //2016-11-01 for (var date = fd; date <= td; date = date.AddDays(1)) { var product = db.Products.Find(todaycooked.ProductID); product.Qty = product.Qty + todaycooked.QTY; todaycooked.Product = product; todaycooked.CookDate = date; db.TodayCookeds.Add(todaycooked); db

The property 'ID' is part of the object's key information and cannot be modified in asp.net mvc

非 Y 不嫁゛ 提交于 2019-12-01 06:53:40
问题 I have used entity framework with code first approach. when I am trying to pass record one by one Fromdate to Todate, 1st time its work, after it gives error like: "The property 'ID' is part of the object's key information and cannot be modified." var fd = todaycooked.CookDate; // 2016-07-01 var td = todaycooked.ToCookDate; //2016-11-01 for (var date = fd; date <= td; date = date.AddDays(1)) { var product = db.Products.Find(todaycooked.ProductID); product.Qty = product.Qty + todaycooked.QTY;

Kendo widgets two level deep in Razor, inline markup blocks cannot be nested

馋奶兔 提交于 2019-11-30 21:58:49
I´m trying to implement Kendo widgets two level deep but the Razor engine keeps complaining: "Inline markup blocks (@Content) cannot be nested. Only one level of inline markup is allowed." Is there a way for the Razor engine to render helpers two level deep? My code example: @(Html.Kendo().TabStrip() .Name("tabStrip") .Items(tabstrip => { tabstrip.Add().Text("Strip1") .Selected(true) .Content(@<text> @RenderPanelBar() </text>); tabstrip.Add().Text("Strip2") .Content(@<text> </text>); }) ) @helper RenderPanelBar(){ @(Html.Kendo().PanelBar() .Name("panelBar") .ExpandMode(PanelBarExpandMode

RazorEngine layouts

谁说胖子不能爱 提交于 2019-11-28 15:53:24
I am using the Razor engine https://github.com/Antaris/RazorEngine to parse the body of my email templates. Is it possible to define a layout and include other .cshtml files? for example a common header and a footer. ministrymason I got common templates and a layout working, with the help of these two posts: RazorEngine string layouts and sections? http://blogs.msdn.com/b/hongyes/archive/2012/03/12/using-razor-template-engine-in-web-api-self-host-application.aspx This is my solution: Solution 1: Layout Used by setting _Layout @{ _Layout = "Layout.cshtml"; ViewBag.Title = Model.Title; } Footer