razor

Base controller method

时光总嘲笑我的痴心妄想 提交于 2019-12-13 19:01:10
问题 My base controller method is not getting executed. Below is my base controller. public abstract class ReportServiceBaseController : Controller { protected ReportServiceBaseController(); [HttpPost] public JsonResult LoadDocumentInfo(LoadDocumentInfoRequest request); [HttpPost] public JsonResult LoadDocumentMapInfo(LoadDocumentMapInfoRequest request); } Below is my derived controller : public class ReportController : ReportServiceBaseController { protected override PerpetuumSoft.Reporting

Load list of roles for each user in MVC5 razor

两盒软妹~` 提交于 2019-12-13 18:33:24
问题 I am trying to display a row of each user and their roles in the ASP.net MVC application. Users and their roles are stored in ASP.net membership provider table. Using the code below I can display each user and the role they are assigned, but my problem is if the user is in multiple roles then the user gets repeated. I tried making UserRole as List but I am now stuck as I do not know how to add the roles to a list in the code below. Could you please provide me some direction? My viewmodel is :

MvcHtmlString with Razor statements included

好久不见. 提交于 2019-12-13 18:27:28
问题 I find myself repeating this code block too often... <div class="form-group"> <div class="col-sm-3 control-label"> @Html.LabelFor(m => m.Name) </div> <div class="col-sm-9"> @Html.TextBoxFor(m => m.Name, null, new { @class = "form-control" }) @Html.ValidationMessageFor(m => m.Name) </div> </div> I have been attempting to create a MvcHtmlString custom extension, but it assumes that the @Html.LabelFor commands are text and that is what is displayed. EDIT: Thanks Joe and Stephen!! That's what I

Force input to be decimal in @Html.Textbox

风格不统一 提交于 2019-12-13 18:26:06
问题 i have a problem. I have a Razor Textbox: @Html.TextBox("imp", amount, new { @class = "alignRight", size = 5 }) I would like that , in input, user will write only decimal values. How can i do? I think jquery could help me...but...what's the id of that textbox? 回答1: Yes you can do via Jquery and Javascript as well function isNumeric(evt) { var c = (evt.which) ? evt.which : event.keyCode if ((c >= '0' && c <= '9') || c == '.' ) return true; return false; } And regarding Id, you can do it via

How can i enforce the scaffolding automatically generated code to display the Label and the EditorFor text field at the same line in my asp.net mvc 3

守給你的承諾、 提交于 2019-12-13 18:17:07
问题 I am developing an asp.net mvc 3 with razor view , i also automatically generate the associated action methods and view using the scaffolding template. But the problem i am facing is that on the view the lable and editorfor input field will be displayed in two separate lines (each on a separate Div )as follow:- <div class="editor-label"> @Html.LabelFor(model => model.FirstName) </div> <div class="editor-field"> @Html.EditorFor(model => model.FirstName) @Html.ValidationMessageFor(model =>

jQuery set date value in asp net core 2 razor

江枫思渺然 提交于 2019-12-13 18:13:23
问题 I have a problem with jQuery in my asp net core razor form. I can change values, using jQuery, in input types like text, but not of type date, I don't know why. Here is part of the Project model, just the property, which I want to change in form: [DataType(DataType.Date)] public DateTime? OnSite { get; set; } [Display(Name = "Opening date")] [DataType(DataType.Date)] public DateTime? OpeningDate { get; set; } Here is the part of Razor form: <div class="form-group"> <label asp-for="Project

PartialView cumulatively adding issue

北城以北 提交于 2019-12-13 18:12:31
问题 I want to make a modular web site.Everything is going well but i have encountered a problem when cumulatively added module.I want to load content dynamically as below: For contact page: Content.cshtml : Lorem ipsum dolor Contact.cshtml Content.cshtml : Adress : Tbilisi/Georgia But load only first content rightly as below Content.cshtml : Lorem ipsum dolor Contact.cshtml Content.cshtml : Lorem ipsum dolor How can i solve this problem? tblModule +---------+-------------------------+ | ModulId |

How to use the RazorViewEngine and a custom IView together?

拜拜、爱过 提交于 2019-12-13 18:12:29
问题 I've spent too much time trying to figure this out. I've not been able to work it out on my own. The following method is in my custom IView. It reads the contents of my views and returns an IView. The problem is that it won't render the razor code within the view. public void Render(ViewContext viewContext, System.IO.TextWriter writer) { //Load File var rawContents = File.ReadAllText(this.viewPhysicalPath); // Able to modify rawContents but Razor code isn't not being rendered. writer.Write

How do i create dynamic properties in Model and use in Controller and View. - MVC

半城伤御伤魂 提交于 2019-12-13 17:15:35
问题 I am looking for a solution which creates dynamic properties to be create in Model. I want to use them in my View and Controller. Can any one have idea, how to create it? I am having scenario in my project where one page will be having options to be lets say Profile2, Profile5 etc. Profile 2 can have two URLs to be submit from user. Profile 5 can have five URLs to be submit from user. and So on........ Is there any solution or alternative to do this???? 回答1: He Amit , For your situation "I am

How can I get precompiled razor files when deploying .NET Web Application?

不问归期 提交于 2019-12-13 16:56:23
问题 I am tasked with improving IIS preloading and initializing of applications on our server. I have implemented application initialization and preload of application on IIS, but still there is a long wait time when recycling/restarting application pool. I have found some useful links which I thought would help me, but I am still not getting precompiled Razor views. I tried to follow this article for RazorGenerator, but it does not seem to work. http://blog.davidebbo.com/2011/06/precompile-your