razor

Razor Pages vs server-side Blazor

99封情书 提交于 2020-02-02 12:56:07
问题 Razor Pages is used for server side web applications, just like in the good old days. Blazor is aiming to provide an alternative to popular JavaScript frameworks (like Angular or React), to create Single Page Applications (SPAs) which runs (mainly) in the clients browser. However, I have also heard about server-side Blazor, which kind of confuses me. According to this answer, server side Blazor is just Razor Components running on the server. But what is the difference between Razor Pages and

Bind multiple radiobuttons to individual booleans

一笑奈何 提交于 2020-02-02 05:17:07
问题 Background I have a model containing three bools public class PageDataModel { public bool setting1 { get; set; } public bool setting2 { get; set; } public bool setting3 { get; set; } } If one value is true, the others must be false. In my view, I am displaying three radio buttons: The Razor code for my view: <div class="row"> <div class="radio"> @if (Model.Setting1) { @Html.RadioButtonFor(m => m.Setting1, "Setting1", new { Checked = "checked", Name = "Group"}) } else { @Html.RadioButtonFor(m

Bind multiple radiobuttons to individual booleans

倾然丶 夕夏残阳落幕 提交于 2020-02-02 05:16:06
问题 Background I have a model containing three bools public class PageDataModel { public bool setting1 { get; set; } public bool setting2 { get; set; } public bool setting3 { get; set; } } If one value is true, the others must be false. In my view, I am displaying three radio buttons: The Razor code for my view: <div class="row"> <div class="radio"> @if (Model.Setting1) { @Html.RadioButtonFor(m => m.Setting1, "Setting1", new { Checked = "checked", Name = "Group"}) } else { @Html.RadioButtonFor(m

How to set a model with a class that inherits partialviewresult

为君一笑 提交于 2020-02-02 04:22:36
问题 I've based a dynamic css solution as mentioned here: Dynamic CSS for ASP.NET MVC? I notice the inherited PartialViewResult only has a getter for the Model, is there another way I can implement this functionality where HttpContext.Response.ContentType = "text/css" and I can send in a model like you can with a partialview? 回答1: Simply adapt the custom action result so that it takes a model: public class CssViewResult : PartialViewResult { public CssViewResult(object model) { ViewData = new

How to set a model with a class that inherits partialviewresult

半世苍凉 提交于 2020-02-02 04:22:32
问题 I've based a dynamic css solution as mentioned here: Dynamic CSS for ASP.NET MVC? I notice the inherited PartialViewResult only has a getter for the Model, is there another way I can implement this functionality where HttpContext.Response.ContentType = "text/css" and I can send in a model like you can with a partialview? 回答1: Simply adapt the custom action result so that it takes a model: public class CssViewResult : PartialViewResult { public CssViewResult(object model) { ViewData = new

How to set a model with a class that inherits partialviewresult

半腔热情 提交于 2020-02-02 04:22:09
问题 I've based a dynamic css solution as mentioned here: Dynamic CSS for ASP.NET MVC? I notice the inherited PartialViewResult only has a getter for the Model, is there another way I can implement this functionality where HttpContext.Response.ContentType = "text/css" and I can send in a model like you can with a partialview? 回答1: Simply adapt the custom action result so that it takes a model: public class CssViewResult : PartialViewResult { public CssViewResult(object model) { ViewData = new

The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'X'

左心房为你撑大大i 提交于 2020-01-31 16:54:05
问题 I am building a solution with Sitecore 7 and ASP.NET-MVC 3 and trying to use a custom model class as described in this blog post by john west. I have seen several other questions here on SO reporting a similar error with ASP.NET-MVC (without Sitecore), usually related to passing the wrong type of object in controller code, or there being a configuration error with the \Views\web.config file, but neither seem to be the issue here. 回答1: this issue is caused when you create a view rendering

How to fix 'Could not load file or assembly 'System.Web.Helpers, Version=2.0.0.0' Error with 2sxc in DNN

微笑、不失礼 提交于 2020-01-30 08:46:59
问题 I have a local DNN site and I am trying to use the 2sxc module to create content/apps before placing it on the actual production site. I tried to install the Razor Tutorial App and when I place it on the page I am given following output: Error: System.IO.FileLoadException: Could not load file or assembly 'System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly

ASP.NET MVC3 RAZOR: File Upload gives zero as file count

混江龙づ霸主 提交于 2020-01-28 10:22:50
问题 I need to upload multiple files into web server using MVC3 with RAZOR. I have the following code. In the controller, I am getting zero as the file count. How to correct it to get the actual number of files being uploaded and to get the content? public class MyFileController : Controller { public ActionResult MyFileProcessActionTest() { return View(); } [HttpPost] public ActionResult MyFileProcessActionTest(IEnumerable<System.Web.HttpPostedFileBase> files) { int fileCount = files.Count<System

ASP.NET MVC3 RAZOR: File Upload gives zero as file count

99封情书 提交于 2020-01-28 10:21:26
问题 I need to upload multiple files into web server using MVC3 with RAZOR. I have the following code. In the controller, I am getting zero as the file count. How to correct it to get the actual number of files being uploaded and to get the content? public class MyFileController : Controller { public ActionResult MyFileProcessActionTest() { return View(); } [HttpPost] public ActionResult MyFileProcessActionTest(IEnumerable<System.Web.HttpPostedFileBase> files) { int fileCount = files.Count<System