razor

Strongly typed Razor views in dynamically loaded assembly don't compile at runtime

一世执手 提交于 2020-01-03 17:07:25
问题 I have a MVC3 Area in an assembly that is dynamically loaded with MEF. If I use the Webforms view engine with strongly typed views, everything works fine. If I use the Razor view engine with a dynamic model, it works fine too. But if I use a strongly typed Razor view , the view compilation fail at runtime. The problem is that the dynamically loaded assembly is not in the list of referenced assemblies passed to the C# compiler. The generated C# code looks like this: namespace ASP { using

Tag helper intellisense in VS 2017 ver 15.3.x not working

て烟熏妆下的殇ゞ 提交于 2020-01-03 17:03:36
问题 In past versions of Visual Studio 2017 if a developer wanted to have tag helper intellisense they needed to install Razor Language Services as indicated in this SO answer: ASP.NET Core Tag Helper Intellisense in Visual Studio 2017 In prior versions of VS 2017 I did this and it worked great. Recently I upgraded to Visual Studio 2017 version 15.3.2 from version 15.2 I believe and now my tag helper intellisense is no longer working. I read here https://developercommunity.visualstudio.com/content

ASP.NET Razor views are not updating when simply updating html

谁说我不能喝 提交于 2020-01-03 17:02:25
问题 ASP.NET Razor views are not updating when simply updating html. I'm trying to add a few elements on a page when my application is running in debug mode, and the changes are not being seen in the browser when I refresh the page. However, if I stop and restart the application, the changes are seen. I've tried disabling cache, sending back headers (pragma no-cache), shift reload on the browser, nothing seems to work. This is quite frustrating having to continually bounce the app. What I'm using:

ASP.NET Razor views are not updating when simply updating html

坚强是说给别人听的谎言 提交于 2020-01-03 17:02:15
问题 ASP.NET Razor views are not updating when simply updating html. I'm trying to add a few elements on a page when my application is running in debug mode, and the changes are not being seen in the browser when I refresh the page. However, if I stop and restart the application, the changes are seen. I've tried disabling cache, sending back headers (pragma no-cache), shift reload on the browser, nothing seems to work. This is quite frustrating having to continually bounce the app. What I'm using:

How to pass a string array from controller to the view MVC4 without creating multiple actionresults?

眉间皱痕 提交于 2020-01-03 16:56:54
问题 I am new to mvc4 so please go easy, i am trying to pass multiple names of destinations from the controller to my view. How can i do this without creating more actionresults and objects. I want to create a table with the destination names using a string array. Is this possible any help would be appreciated. Thank You in advance. Controller: public ActionResult Destinations() { string[] arrivalAirport = new string[4] { "london", "paris", "berlin", "manchester" }; Destination dest = new

Dismiss and submit form Bootstrap 3

穿精又带淫゛_ 提交于 2020-01-03 14:00:43
问题 I have a bootstrap modal dialog that is inside a form. The form is submitted via AJAX. I want the submit button to also dismiss the modal (otherwise i end up with the modal overlay remaining) Code for the modal is: @using (Ajax.BeginForm("SaveConfiguredReport", new AjaxOptions { HttpMethod = "POST", InsertionMode = InsertionMode.Replace, UpdateTargetId = "report-details", OnBegin="preProcessing" })) { <div class="modal fade" id="add-filter-dialog" tabindex="-1" role="dialog" aria-labelledby=

Use Sections in Partial Views in MVC 4.0

半世苍凉 提交于 2020-01-03 11:15:09
问题 I want to include scripts in my partial views when I have cases where I need to initialize jQuery ui on specific elements. It really belongs with the partial and not the containing page or the layout. Supposedly there's a way to do it in MVC 4, but I can't seem to find any info on it. 回答1: I also had a similar issue. Hope this helps. We wanted to have a view that contains a common header section that displays some data and another section that should dynamically change when we click on a link

Razor View Syntax doesn't recognize the “@” in an HTML attribute

你离开我真会死。 提交于 2020-01-03 10:58:32
问题 I am migrating a project from MVC 2 to MVC3 and the razor view engine. In MVC 2, I would have the following html: <div id="del_<%= Model.ActivityID.ToString() %>"></div> When using razor, I tried the following, which renders the literal text "del_@Model.ActivityID.ToString()" when I want del_1. <div id="del_@Model.ActivityID.ToString()"></div> To get around the issue, I used: <div id="@Model.ActivityID.ToString()_del"></div> Is there away to make razor work with this syntax? <div id="del_

“Element not closed” error after upgrading from MVC3 to MVC4

只谈情不闲聊 提交于 2020-01-03 10:46:09
问题 Razor 2 (which ships with MVC4) doesn't seem to be fully backwards compatible with Razor 1 (from MVC3). Since upgrading, I found an error: The "td@Html.Raw(count" element was not closed. All elements must be either self-closing or have a matching end tag. The code that caused this was: <td@Html.Raw(count == null ? null : " class='has-item'")> What is the solution to this? 回答1: The Razor parser was re-written for MVC 4, presumably because: The HTML5-specs clearly states that unclosed HTML-tags

Simple html vs extension methods in Razor (preference)

流过昼夜 提交于 2020-01-03 09:46:06
问题 For Simple tags in MVC Razor do you prefer to use simple HTML or use extension methods eg <label for="male">Male</label> Or @Html.Label("male", "Male") I feel it is sometime more easier to use the simple HTML. Extension methods make sense when you want to do some custom code. 回答1: Depends. If the male element you are associating this label to is rendered with a html helper like: @Html.TextBoxFor(x => x.Male) then I would use a Html.LabelFor and keep the lambdas and strong typing. Also I would