razor

Url.Action not outputting URL

折月煮酒 提交于 2019-12-24 03:20:55
问题 I'm using Url.Action so that I can create more complex HTML links as ActionLink doesn't allow HTML inside them. Example: <a class="uiButton" href="@Url.Action("Areas","Organisations","Manage","Create")" title="New Organisation"> <span class="icon organisations-new">New Organisation</span> </a> However the URL doesn't appear in the href ? Any ideas why ? :/ 回答1: You are using this overload of Url.Action public string Action( string actionName, string controllerName, Object routeValues, string

404.15 not found MVC4 RazorJS

五迷三道 提交于 2019-12-24 03:12:53
问题 I'm using RazorJS in my MVC4 application for using the Razor syntax "@" in the Js file. //Code: @Html.RazorJSInclude("~/Scripts/Application/Transactions.js") <button id="btnSearch" name="submit" type="button" onclick="Loadgrid();">Search</button> The "Transaction.js" has "LoadGrid" mehtod inside. When i use my Transaction.js as the above code it throws me error as "No such method(Loadgrid) is found". The rendered HTML in the browser shows like, <SCRIPT src="/razorjs.axd?fn=/Scripts

Why does Nancy.Testing fail when @using statements are included in razor layouts?

≯℡__Kan透↙ 提交于 2019-12-24 03:05:45
问题 In a previous question Does Nancy.Testing support nested Razor views? I outlined the difficulties I was having with Nancy unit tests failing when presented with nested razor layouts. After investigation I can now refine that information. The problem is not related to nesting it is simply this: If you include a @using statement in a razor layout or view, then Nancy will fail to find that referenced namespace if accessed from a unit-test. For example: Master Layout @inherits Nancy.ViewEngines

Why does Nancy.Testing fail when @using statements are included in razor layouts?

偶尔善良 提交于 2019-12-24 03:05:37
问题 In a previous question Does Nancy.Testing support nested Razor views? I outlined the difficulties I was having with Nancy unit tests failing when presented with nested razor layouts. After investigation I can now refine that information. The problem is not related to nesting it is simply this: If you include a @using statement in a razor layout or view, then Nancy will fail to find that referenced namespace if accessed from a unit-test. For example: Master Layout @inherits Nancy.ViewEngines

MVC3 razor Error in creating HtmlButtonExtension

梦想与她 提交于 2019-12-24 02:55:06
问题 I am trying to create a custom html button on my page using this public static class HtmlButtonExtension { public static MvcHtmlString Button(this HtmlHelper helper, string text, IDictionary<string, object> htmlAttributes) { var builder = new TagBuilder("button"); builder.InnerHtml = text; builder.MergeAttributes(htmlAttributes); return MvcHtmlString.Create(builder.ToString()); } } When I click this button I want to pass an recordID to my Action Given below is what I added to my razor view

Disable Razors default .cshtml handler in a ASP.NET Web Application

我只是一个虾纸丫 提交于 2019-12-24 02:37:06
问题 Does anyone know how to disable the .cshtml extension completely from an ASP.NET Web Application? In essence I want to hijack the .cshtml extension and provide my own implementation based on a RazorEngine host, although when I try to access the page.cshtml directly it appears to be running under an existing WebPages razor host that I'm trying to disable. Note: it looks like its executing .cshtml pages under the System.Web.WebPages.Razor context as the Microsoft.Data Database is initialized. I

Model binder ValueProvider appends to the existing value + MVC 4

僤鯓⒐⒋嵵緔 提交于 2019-12-24 02:33:15
问题 I have the below method in my model binder: protected override object CreateModel(ControllerContext controllerContext, ModelBindingContext bindingContext, Type modelType) { if (bindingContext.ValueProvider.GetValue("Id") == null) { string s = bindingContext.ValueProvider.GetValue("IsSoftDeleted").AttemptedValue; bool d = Convert.ToBoolean(s); return OrgFactory.Create(bindingContext.ValueProvider.GetValue("Caption").AttemptedValue, bindingContext.ValueProvider.GetValue("NameInUse")

Change ordering in MVC3 Index view

折月煮酒 提交于 2019-12-24 02:27:06
问题 Would like to have clickable column titles eg click on TagCode once and it orders by that, and again it reverses. Same for Number. Using MVC3/Razor and LightSpeed (ORM). I know that a grid eg http://mvccontrib.codeplex.com/ may be the way forward. But as I don't need paging or filtering, I'd like to keep it simple for now. Problem Is there a simple example of code (maybe with an up/down icon) that would help? 回答1: @Dave Sorry, I missed your main point in my first answer If you want to

ServiceStack Razor - Html.RenderAction equivalent

孤者浪人 提交于 2019-12-24 02:25:06
问题 I have the requirement to use Html.RenderAction like you would in ASP.NET MVC. For instance I have a Home Page with News and Products on. I would like to do for instance @Html.RenderAction("/api/products/featured") Which would start a new service call and output the template to the html stream. Is this possible using ServiceStack Razor and if so how do I accomplish it? 回答1: The PartialExamples.cshtml test page shows different examples of rendering a razor view inside a page, e.g: Using the

ASP.NET MVC Html.Editor pass model to Editor Template

北城余情 提交于 2019-12-24 02:16:06
问题 I have an Editor Template called "Address.cshtml" that has a model defined as: @model Acme.Models.Address In a View I want call the Editor Template and pass a local variable of the same type, and define the name it will use for the variables, I've tried a number of things including: @Html.Editor("address", "Address", new { Model = address }) How do I pass the model? Note, I cannot use @Html.EditorFor() because the view uses a different model. 回答1: The only purpose of EditorFor is to work with