razorengine

Pass Table Value from View to Controller MVC

天大地大妈咪最大 提交于 2019-12-06 15:57:30
Can I pass table td values to controller? View strongly typed: @using (Html.BeginForm("PostClick", "Vendor", FormMethod.Post)) { <table class="tblData"> <tr> <th> @Html.DisplayNameFor(model => model.First().SubmittedDate) </th> <th> @Html.DisplayNameFor(model => model.First().StartDate) </th> </tr> <tr> <td> @Html.DisplayFor(modelItem => item.SubmittedDate) </td> <td> @Html.DisplayFor(modelItem => item.StartDate) </td> </tr> </table> <input type="submit" value="submit" /> } Contoller code: public void PostClick(FormCollection collection) { /*Some Code */ } How to pass table value from view to

RazorEngine and Visual Studio 2015 IntelliSense

☆樱花仙子☆ 提交于 2019-12-06 01:35:38
This post is not about ASP.NET MVC. I am using RazorEngine for template processing available here: https://antaris.github.io/RazorEngine/ The documentation states that I can have IntelliSense if I follow the instructions below: https://antaris.github.io/RazorEngine/IntellisenseAndResharper.html However, VS shows the following error: The type or namespace name 'RazorEngine' could not be found (are you missing a using directive or an assembly reference?) Also the following errors: The type or namespace name 'Linq' does not exist in the namespace 'System' The type or namespace name 'Helpers' does

Public Conditional Razor Views with minified JS and CSS

烈酒焚心 提交于 2019-12-05 18:44:14
I am using ASP.NET MVC 5 to develop my website. I'm using Grunt to minify my CSS and JS. Everything works fine, but I need to change the route source of my files if I'm making a publish (release mode) or I'm debugging (I need to read my CSS and JS clearly). Something like this: [Debug Mode] <script src="scripts/myscript.js"></script> [Relase Mode or Public Mode] <script src="dist/myscript.min.js"></script> I have read this post on StackOverflow( Razor view engine, how to enter preprocessor(#if debug) ) and I don't like the proposed solution because I think (not sure) that the loaded Razon View

A DbContext instance cannot be used inside OnConfiguring since it is still being configured at this point

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 06:17:52
I'm trying to build a custom view location system. public class myViewLocationExpander : IViewLocationExpander { private myDBContext _context; public myViewLocationExpander (myDBContext context) { _context = context; } public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations) { _context.Property.//..... //Error happened here Some other codes } And in my startup file public void ConfigureServices(IServiceCollection services) { //other codes services.AddMvc(); services.Configure<RazorViewEngineOptions>(options => { options

RazorEngine Error trying to send email

倾然丶 夕夏残阳落幕 提交于 2019-12-05 02:42:49
I have an MVC 4 application that sends out multiple emails. For example, I have an email template for submitting an order, a template for cancelling an order, etc... I have an Email Service with multiple methods. My controller calls the Send method which looks like this: public virtual void Send(List<string> recipients, string subject, string template, object data) { ... string html = GetContent(template, data); ... } The Send method calls GetContent , which is the method causing the problem: private string GetContent(string template, object data) { string path = Path.Combine(BaseTemplatePath,

Using-Statement in RazorEngine (without the HtmlHelper from MVC)

别等时光非礼了梦想. 提交于 2019-12-04 04:48:22
I'm using the RazorEngine without the MVC-Framework. That means I don't have the HtmlHelper for creating templates. That's fine, I don't need any methods from it anyway. But I need to create my own methods like the BeginForm. Now those are done with HtmlHelper.ViewContext.Writer.Write, which I don't have. Is there a "out of the box"-way to do that, or do I have to do some magic here? The RazorEngine is designed with deriving your own types for use in the Engine itself. First create your own Helpers: public class RazorHtmlHelper { public IEncodedString Partial(string viewName) { ITemplate

RazorEngine un-cache compiled templates

别等时光非礼了梦想. 提交于 2019-12-03 23:45:35
Currently, I am using RazorEngine v2.1 as part of a background process that sends templated emails (thousands of them). To speed things up, the templates are compiled with their md5 sum as a name. This makes it so that when a template is changed, it is re-compiled and all emails using the template are able to use the same compiled template. I keep track of the names of the compiled templates in a list so that I know when to call compile again (and do a few other things). The problem : It has occurred to me that after a really long time and after lots of template modifications that all these

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

懵懂的女人 提交于 2019-12-03 20:54:06
问题 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>); }) )

How to make intellisense works with RazorEngine?

扶醉桌前 提交于 2019-12-03 10:10:39
I am trying to configure RazorEngine so that intellisense works on views. I add RazorEngine and Microsoft.AspNet.Mvc using nuget. I create TestView.cshtml and declare @model MyModel but it says The name 'model' does not exist in the current context . I also cannot use intellisense inside the view. Do I miss any step here? How to enable intellisense in the View? You can use @using RazorEngine.Templating @using Namespace.Of.My.Model @inherits TemplateBase<MyModel> on the top of your template. This works fine on a new Console Application with Visual Studio 2013 (after adding a reference to

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

半城伤御伤魂 提交于 2019-12-02 21:20:52
问题 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