razor

ActionMailer.Net Stand-Alone: There is no build provider registered for the extension '.cshtml'

狂风中的少年 提交于 2019-12-18 11:51:42
问题 I need to send emails from a Windows Service and came across ActionMailer.net, a templated email system that can be used either within an ASP.Net MVC application or stand-alone. Following the stand-alone tutorial http://geeksharp.com/2011/07/06/actionmailer-0-6-released/ I'm at the point where I'm creating a View. However, when I type any text into the view it's underlined with a blue squiggle. Mousing over the blue squiggle reveals an error message in a tool tip: There is no build provider

.LESS together with Razor

泪湿孤枕 提交于 2019-12-18 11:42:34
问题 Is it possible to use Razor View Engine (ASP.NET MVC) together with .LESS (similar to SASS - http://lesscss.org/ for .NET), since they're both using "@blah"? What I want to achieve is to create .LESS css files, mixed with Razor. UPDATED: Sorry for being a bit unspecific. What I want to do is to use Razor View Engine WITHIN the .less (dotlesscss) css files. This would be nice in order to e.g. pass site-settings like Theme customized from an admin into the css file. Problem is that the syntax

Razor Host Factory error

a 夏天 提交于 2019-12-18 11:42:05
问题 I get a MvcWebRazorHostFactory error trying to run my app, but it's not an MVC app at all. I have the following web packages installed via nuget: Microsoft ASP.NET Razor Microsoft ASP.NET Web API 2.1 Microsoft ASP.NET Web Pages My app is angularjs front end using razor views (.cshtml). I don't understand why I keep getting this error. An exception of type 'System.InvalidOperationException' occurred in System.Web.WebPages.Razor.dll but was not handled in user code Additional information: Could

How to get query string parameter from MVC Razor markup?

此生再无相见时 提交于 2019-12-18 10:58:09
问题 I want to check the URL parameter in my Razor markup. For example, how do I do something like this: <div id="wrap" class="@{if (URL "IFRAME" PARAMETER EQUALS 1) iframe-page}"> 回答1: Similar thread <div id="wrap" class=' @(ViewContext.RouteData.Values["iframe"] == 1 ? /*do sth*/ : /*do sth else*/')> </div> EDIT 01-10-2014: Since this question is so popular this answer has been improved. The example above will only get the values from RouteData , so only from the querystrings which are caught by

Html.LabelFor Specified Text

僤鯓⒐⒋嵵緔 提交于 2019-12-18 10:46:21
问题 Anyone got any idea on how to specify text when using Html.LabelFor(c=>c.MyField) . It's just MyField might not be an appropriate name to display on screen, you may want "The Super Fantastic Field" instead, but there doesn't appear to be any overloads. Any ideas? 回答1: You use System.ComponentModel.DataAnnotations.DisplayAttribute: [Display(Name = "My Field")] public string MyField { get; set; } Setting the ResourceType property on your attribute will allow you to use a resource file. (Prior

What's the difference between Html.Label, Html.LabelFor and Html.LabelForModel

我怕爱的太早我们不能终老 提交于 2019-12-18 10:44:29
问题 What's the difference between @Html.Label() , @Html.LabelFor() and @Html.LabelForModel() methods? 回答1: Html.Label gives you a label for an input whose name matches the specified input text (more specifically, for the model property matching the string expression): // Model public string Test { get; set; } // View @Html.Label("Test") // Output <label for="Test">Test</label> Html.LabelFor gives you a label for the property represented by the provided expression (typically a model property): //

How to add .aspx pages to existing MVC 4 project?

老子叫甜甜 提交于 2019-12-18 10:43:00
问题 I have working ASP.NET MVC 4 project. I want to add to this MVC project 2 .aspx pages of another WebForms project. I have several questions: Where should I copy this .aspx files and how should I config my routes? How should I tell this .aspx pages to use ~/Shared/_Layout.chtml as a master page? Additionally this .aspx pages uses .ascx controls . Where should I store them? How should I modify web.config file? I have looked at the links posted in this question, but they seemed to be outdated. A

Exclude/Remove Value from MVC 5.1 EnumDropDownListFor

一个人想着一个人 提交于 2019-12-18 10:39:11
问题 I have a list of enums that I am using for a user management page. I'm using the new HtmlHelper in MVC 5.1 that allows me to create a dropdown list for Enum values. I now have a need to remove the Pending value from the list, this value will only ever be set programatically and should never be set by the user. Enum: public enum UserStatus { Pending = 0, Limited = 1, Active = 2 } View: @Html.EnumDropDownListFor(model => model.Status) Is there anyway, either overriding the current control, or

Add item into List from View and pass to Controller in MVC5

℡╲_俬逩灬. 提交于 2019-12-18 10:36:29
问题 I have a form like this: JS Code: $(document).ready(function() { $("#add-more").click(function() { selectedColor = $("#select-color option:selected").val(); if (selectedColor == '') return; var color = ' < div class = "form-group" > < label class = "col-md-2 control-label" > Color: < /label> < div class = "col-md-5" > < label class = "control-label" > ' + selectedColor + ' < /label></div > < /div> '; var sizeAndQuantity = ' < div class = "form-group" > < label class = "col-md-2 control-label"

ASP.NET MVC 3, Razor Views, and Portable Areas

那年仲夏 提交于 2019-12-18 10:24:58
问题 I am trying to using portable views with ASP.NET MVC 3 and razor views as that seems like the best way to create an easy plug-in architecture. So I have my class library setup and I have my view located in /Views/Admin/Index.cshtml and it is set as an Embedded Resource. I then include that project as a dependency for the main web application project. When I try to access the Admin controller, Index action I get a message that is can't find that view file (so the controller is being properly