razor-2

JQuery submit intervention doesn't add parameter required in Controller method

£可爱£侵袭症+ 提交于 2019-12-12 01:16:10
问题 I have 4 submit buttons on my View and in order for them to call the right method in the controller I added a JQuery POST function. Dependant on what buttons I click in the View I want the Controller to calculate whatever operation was selected. The JQuery correctly links my View with the Controller (the debugger first stops in the JQuery, then in the controller), however it doesn't seem to pass the parameter operation (needed in CalculationValidation(Model, String) ). So it ends up reloading

TempData Message in different tab

前提是你 提交于 2019-12-11 23:53:50
问题 i want in my page after an action like RegisterUser give a message to client for result.so i use TempData(becase i use RedirectToAction method i cant use viewbag).my problem is that if user open another tab in same time message will show in another tab(any page it can be).how can i solve that?? @using (@Html.BeginForm("RegisterUser", "UserManagement", FormMethod.Post)) { @Html.AntiForgeryToken() @Html.Partial("_RegisterPagesMessage") <table class="Registertbl"> <tr> <td>نام*</td> <td> @Html

Razor template containing page parts that mustache will render on client

寵の児 提交于 2019-12-11 12:25:40
问题 My page contains parts that will render on the client. The problem I'm having is that razor does not render the parts as I expect them to. For example: <script type="x-tmpl-mustache" id="filterTemplate"> <img id="showFilter" src="~/Content/Image/arrow.png" /> </script> Will not render the ~ sign, only when I place img outside of the script tags will it do as expected. This is published in different application paths so I need razor to figure out what ~ is and replace it with the application

Cannot find view located in referenced project

独自空忆成欢 提交于 2019-12-11 10:32:40
问题 My solution consist of 2 projects: MyApp.Rest MyApp.Core Core uses Razor templating to generate emails and reports. Rest is a WebAPI only and references Core. Rest has the startup file, where Razor configuration takes place. Core will also be used by other projects in the future. The problem is I am not able to make the view engine to locate view files even though I have added the output directory as a FileProvider for razor and the template has been copied to the output directory. Output

Url Routing ASP.NET WebPages (.cshtml) without MVC

僤鯓⒐⒋嵵緔 提交于 2019-12-11 09:04:34
问题 How can I route an url to a .cshtml page? E.g. www.example.com/view/2 --> view.cshtml I don't want to use MVC and preferably not complicate things with controller code and other stuff. Just a routing as simple as possible. 回答1: Simple routes like the one where you just want to reach an existing file name without the extension work by default in a Web Pages site. The 2 is accessible in the UrlData collection. Here's an article that explains how the rudimentary routing system works in Web Pages

Unobtrusive validation fails when a Checkbox is on the form

青春壹個敷衍的年華 提交于 2019-12-11 07:23:53
问题 I have a simple Login page that suddenly (After upgrading Jquery.js and Jquery-ui.js to 1.10.2 and 1.10.3 respectively) started to actually reach the action result instead of showing the client side validation messages defined on the E.F Data Annotations. So I found out that removing the only CheckBoxFor that I have besides the User and Password, the submit button actually works as it should be so that it raises client validations only without reaching the controller. Any reason for this

Boolean string comparison in conditional attribute with MVC4 / Razor 2 returns unexpected results

拟墨画扇 提交于 2019-12-11 03:18:55
问题 After upgrading my MVC 3 solution to MVC 4 with Razor 2 I came across the following problem. This code in a view @{ string main = "archive"; } <div class="selected-@(main == "archive")"></div> returns this in MVC 3 <div class="selected-True"></div> and this in MVC 4 <div class="selected-class"></div> which breaks my CSS. Is that a bug introduced by the new conditional attribute feature in Razor 2? My workaround is this: <div class="selected-@((main == "archive").ToString())"></div> which

Getting a HttpCompileException in ServiceStack Razor view (Self hosted)

核能气质少年 提交于 2019-12-10 22:14:56
问题 ASSEMBLY 1 This is my project structure (I serve up content from embedded resources): Common_Assembly.dll Css Common.css Views Shared _Layout.cshtml This also has a class called Model.cs, which is essentially just: public class Model { public string Title {get; set; } } _Layout.cshtml @model MyNameSpace.Model <html> <head> <script language="javascript" href="css/common.css"></script> <title>@Model.Title</title> </head> <body> @RenderBody </body> </html> ASSEMBLY 2 I then have a second

How to get sequence/array index in Editor Template?

谁说我不能喝 提交于 2019-12-10 01:04:53
问题 Case: I have a list of items of Class X displayed using Editor Template for Class X. Problem: How can I get index of an item being processed on the inside of the Editor Template? 回答1: I've been using this HtmlExtension that returns only the needed id of an iteration. It's basically a regex on ViewData.TemplateInfo.HtmlFieldPrefix that's capturing the last number. public static class HtmlExtensions public static MvcHtmlString Index(this HtmlHelper html) { var prefix = html.ViewData

Using If statement in a MVC Razor View

筅森魡賤 提交于 2019-12-09 09:31:55
问题 In the following code, If I use "@If" statement ,I get the following compile code error as " The name 'grid' does not exist in the current context. @if (Model.SModel != null) { @{ WebGrid grid = new WebGrid(Model.SModel); } } else { } @grid.GetHtml() , But the code compiles without the "If" statement.For example @{ WebGrid grid = new WebGrid(Model.SModel); } @grid.GetHtml(). What is the syntactical error in using If else statement 回答1: grid isn't declared outside of the scope of your if