razor

Error Creating Custom ContentPart Orchard CMS

故事扮演 提交于 2019-12-24 18:13:07
问题 I am getting the error "The model item passed into the dictionary is of type 'Orchard.UI.Zones.ZoneHolding', but this dictionary requires a model item of type'First.Module.Models.PersonListPart'" , when entering the editor page for the content in the admin dashboard. My content driver looks like: public class PersonListPartDriver : ContentPartDriver<PersonListPart> { protected override DriverResult Display( PersonListPart part, string displayType, dynamic shapeHelper) { return ContentShape(

Loading/Please-Wait Pop-Up in MVC View

谁说我不能喝 提交于 2019-12-24 17:20:00
问题 I have developed a web application using MVC architecture. My controller takes some time to process input, send it to the server and return it back to the view. I want a Loading/Please-wait kind of pop-up to be shown and exited automatically when the ActionResult returns the view. The corresponding part in my controller looks like this: [HttpPost][STAThread] public ActionResult Index(DropDownModel model) { BillingToolInterface_1.Program p = new BillingToolInterface_1.Program(state, billtype,

How do I use Debug.Writeline in a razor file?

自作多情 提交于 2019-12-24 17:06:16
问题 I'm trying to use Debug.Writeline in a razor web page and I keep getting invalid arguments messages. @System.Diagnostics.Debug.WriteLine("asdf"); returns CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments 回答1: Debug.WriteLine does not return a value so it can't be written out using @ . Try: @{System.Diagnostics.Debug.WriteLine("asdf");} 来源: https://stackoverflow.com/questions/21638874/how

In ASP.NET MVC5, how can I hide the Action name when an a tag is generated in Razor using Url.Action?

倖福魔咒の 提交于 2019-12-24 15:19:07
问题 As the title says. I have a route set up and working fine, which provides a default action when none is specified. I just want to hide the action from the URL because it's unnecessary clutter. Setting the "ActionName" parameter as null , or "" , will just result in the current page's action being substituted instead - which doesn't work. I'm open to using @Html.ActionLink() if that will get me what I need. My route definition is routes.MapRoute( name: "MyBookRoute", url: "Book/{id}", defaults

Passing a custom model into a Umbraco Partial View and getting object casting error

寵の児 提交于 2019-12-24 14:34:47
问题 I am trying to create a custom model and pass it to my partial view but I keep getting this error Unable to cast object of type 'Umbraco.Web.PublishedCache.XmlPublishedCache.XmlPublishedContent' to type 'BlogPostModel' and cant understand why. I have 3 models, BlogPostModel which inherits from HomeModel which inherits from BaseLayoutModel. BlogPostModel.cs public class BlogPostModel : HomeModel { public BlogPostModel(RenderModel model) : base(model) { } public IPublishedProperty MainBlogImage

Resharper is suddenly showing red for Razor syntax

坚强是说给别人听的谎言 提交于 2019-12-24 14:26:04
问题 I don't know, all of sudden Razor syntax showing in Red. I suspended and resumed and also closed VS and restarted still the same. Anything else to do? 回答1: Check the references in the /Web.config and the Views/Web.config. If they are correct, try a clean and rebuild. If that still does not work, you can manually delete the bin folder and VS will recreate it anew. 来源: https://stackoverflow.com/questions/29898607/resharper-is-suddenly-showing-red-for-razor-syntax

Using System.Device in an MVC project

元气小坏坏 提交于 2019-12-24 13:58:56
问题 This doesn't seem to make sense. I'm trying to use the System.Device library in a project to take advantage of the geo location functionality. I'm adding code to a Razor page as I usually do. I have a reference to the library and I've added the using to the top of the razor view: @using System.Device; Device has a red underline because it cannot be found. Typing System.D does not yield Device in intellisense. This doesn't seem to make sense as the library is definitely referenced. The web

Show current search paths for a view

烂漫一生 提交于 2019-12-24 13:33:47
问题 I'm trying to troubleshoot a view and why it can't find the editor templates. Obviously it has to do with how we've configured the search paths in the CustomRazorViewEngine , but just looking at it, it should be working. Instead, it's rendering the default MVC editor templates, because it can't find the custom ones. How can I display the list of search paths for a view, or trigger an error so that it shows me the search paths it's looking for? 回答1: This may not be the best way, but adding

How to get the View to return the ID via a ViewModel to the controller?

纵然是瞬间 提交于 2019-12-24 12:29:58
问题 I currently have a view which returns an IEnumerable collection of Technicians via the TechnicianViewModel . The view model populates fine and displays the objects correctly. However, at the moment I need someone to point me in the right direction with regards to selecting a specific technician. If I was to click More Info on the technician, an [HttpGet] request would be initiated which would result in a queryString. And this is exactly what is against the requirements of this project.

Razor Language Services extension is crashing VS2017

匆匆过客 提交于 2019-12-24 11:44:38
问题 I recently updated my VS 2017 to address git vulnerability issue and now it seems like it keeps crashing when I build my solution from the command line -- if I have a Razor view open in the editor. It restarts VS2017 with a yellow bar: A Previous session terminated unexpectedly. Disabling extension 'Razor Language Services 15.3.30918' might help prevent similar issues. Disable this extension... I tried disabling the extension but then it can't open my Razor views because it doesn't have Razor