razor

Why the jQuery Selectable plugin doesn't work with a foreach generated list?

旧时模样 提交于 2019-12-24 06:59:20
问题 I am currently working on an MVC project and implemented jQuery Selectable plugin. I have a string in my model which I have Split() as below in my view: @{ var size = Model.AvailableSizes.Split(','); foreach (var item in size) { <ol class="ui-selectable" id="selectable"> <li class="ui-selectable">@item</li> </ol> } } Here is the static script defined in my view: <script type="text/javascript"> $(document).ready(function () { $("#selectable").selectable(); }); </script> The selectable jQuery

Why the jQuery Selectable plugin doesn't work with a foreach generated list?

旧街凉风 提交于 2019-12-24 06:59:07
问题 I am currently working on an MVC project and implemented jQuery Selectable plugin. I have a string in my model which I have Split() as below in my view: @{ var size = Model.AvailableSizes.Split(','); foreach (var item in size) { <ol class="ui-selectable" id="selectable"> <li class="ui-selectable">@item</li> </ol> } } Here is the static script defined in my view: <script type="text/javascript"> $(document).ready(function () { $("#selectable").selectable(); }); </script> The selectable jQuery

ASP.NET MVC 3 PagedList. The method 'Skip' is only supported for sorted input in LINQ to Entities.

假如想象 提交于 2019-12-24 06:58:46
问题 Why is it it gives error in return View(contacts.ToPagedList(pageNumber, pageSize)); statement the error in the Index method : The method 'Skip' is only supported for sorted input in LINQ to Entities. The method 'OrderBy' must be called before the method 'Skip'. using System; using System.Collections.Generic; using System.Data; using System.Data.Entity; using System.Linq; using System.Web; using System.Web.Mvc; using PhoneBook.Models; using PagedList; namespace PhoneBook.Controllers { public

dynamic radiobutton in razor

那年仲夏 提交于 2019-12-24 06:49:01
问题 I am using razor view engine and having a bit of trouble creating a list of radiobutton . I am populating a table with a for loop with the values of my model in my view. at each row I want to have a radiobutton . I want to be able to select just one row and get the related items id from the model and submit it to another page. I know how to post. I actually achieved this by using checkbox . But the problem with checkbox is that it allows multiple selection. So I guess I need to use

Conditional Html attribute using razor @html helpers

孤街浪徒 提交于 2019-12-24 06:38:22
问题 I'm trying to add a disable attribute to the html that is generated via @html helper functions but can't seem to get something working that works in the attrib parameters of the html helper. what i have below will still write disabled for the html... but i can't remove it cause then the helper doesn't work. i have a variable defined: @{ var displayItem = (Model.TypeId == 100) } @Html.TextBox("listitem", "", new {@class = "form-control", @disabled = (@displayItem ? "" : "disabled")}) but

Asp.net MVC ReturnUrl variable not showing up with method FormMethod.Post in Html.BeginForm

荒凉一梦 提交于 2019-12-24 06:35:29
问题 The default template in MVC3 sets a 'returnurl' variable in the query string of the logon page. This page then posts back to a controller @using (Html.BeginForm()) { That is then picked up in the controller like so [HttpPost] public ActionResult LogOn(LogOnModel model, string returnUrl) { I wanted to add a CSS class to the form so I changed the helper to: @using (Html.BeginForm("LogOn", "Account", FormMethod.Post, new { @class = "form-horizontal" })) But now information in the query string

Razor Chart Helper: How to change AxisX text orientation

左心房为你撑大大i 提交于 2019-12-24 06:23:09
问题 In a view, I can not change the orientation of the text of the labels of the X axis I tried to add a property in a theme but this does not seem to work. Do you have an idea for it to work? @{ string myTheme = "<Chart>\r\n <ChartAreas>\r\n <ChartArea Name=\"Default\" _Template_=\"All\">\r\n <AxisX TextOrientation=\"Rotated90\" Interval=\"1\" />\r\n </ChartArea>\r\n </ChartAreas>\r\n \r\n \r\n</Chart>"; var myChart = new Chart(width: 600, height: 400, theme: myTheme) .AddSeries( name: "test ",

Razor Chart Helper: How to change AxisX text orientation

蓝咒 提交于 2019-12-24 06:23:06
问题 In a view, I can not change the orientation of the text of the labels of the X axis I tried to add a property in a theme but this does not seem to work. Do you have an idea for it to work? @{ string myTheme = "<Chart>\r\n <ChartAreas>\r\n <ChartArea Name=\"Default\" _Template_=\"All\">\r\n <AxisX TextOrientation=\"Rotated90\" Interval=\"1\" />\r\n </ChartArea>\r\n </ChartAreas>\r\n \r\n \r\n</Chart>"; var myChart = new Chart(width: 600, height: 400, theme: myTheme) .AddSeries( name: "test ",

Handling ASP.NET MVC Routing in External JavaScript

扶醉桌前 提交于 2019-12-24 06:04:58
问题 What's the best way to avoid hardcoding URL's in JavaScript (primarily used when making AJAX calls)? In the past: Render JavaScript variable with result of @Url.Action or @Url.RouteUrl Pass result of @Url.Action or @Url.RouteUrl to JavaScript in init/ctor. Is there a better way? It would be good to do something like this: var url = $.routes("actionName", "controllerName") // or "routeName" for named routes $.post(url, { id = 1 }, function() { //.. }); Which of course isn't really possible

Syntax highlighting and intellisense not working .net core vs 2015

落爺英雄遲暮 提交于 2019-12-24 05:52:46
问题 I am trying to work on a .net core project and syntax highlighting is not functioning properly for razor views. Is there a dev dependency or configuration property that I am missing. Intellisense is also not working properly for asp-* tags. Any suggestions? I've already tried deleting the ComponentModelCache in appdata. Here is my project.json so you can see what packages I'm using. It seems to be project setup related, most likely a package. I am importing the tag helpers in my _ViewImports