asp.net-mvc-5

MVC Validation on Subviews

烈酒焚心 提交于 2019-12-25 04:32:13
问题 I am working on a Sitecore/MVC application, my first MVC application so I am learning as I go. No doubt I am going wrong somewhere along the line. I have a Basket that has 2 address views on it, one for billing and another for delivery. There is also a checkbox for "Delivery the same as billing" allowing the user to complete just one address. When you user checks this checkbox the delivery address div collapses. Main view: <div class="pure-control-group"> <h2>Billing Address</h2> @Html.Action

HttpServerUtility.Execute blocked while waiting for an asynchronous operation to complete

纵饮孤独 提交于 2019-12-25 04:30:13
问题 I have an asp.net mvc app with a partial view to render the User Profile Name @{ Html.RenderAction("GetPropertiesForUser", "UserProfile"); } @model Inspinia_MVC5_xx.Models.UserProfile <div class="dropdown profile-element"> <span> <img alt="image" class="img-circle" src="~/Images/profile_small.jpg" /> </span> <a data-toggle="dropdown" class="dropdown-toggle" href="#"> <span class="clear"> <span class="block m-t-xs"> <strong class="font-bold">@Model.displayName</strong> </span> <span class=

MVC MultiSelect EF many to many Edit

别等时光非礼了梦想. 提交于 2019-12-25 04:29:44
问题 Below is my code that saves a multi select box, it works fine, but when i try to edit a record i get the error below. Whats the best way to add just the additional selected tags, and to remove any unselected tags when editing? failed because another entity of the same type already has the same primary key value. This can happen when using the 'Attach' method or setting the state of an entity to 'Unchanged' or 'Modified' if any entities in the graph have conflicting key values. This may be

C#: Return any item that matches the condition

戏子无情 提交于 2019-12-25 04:09:40
问题 I have a method like this: public ActionResult ShowAvailableSpots(int Id, DateTime ArrivalDate, DateTime LeaveDate) { var query2 = db.Spots .Where(c => db.Reservations.Any(r => DbFunctions.TruncateTime(ArrivalDate) <= DbFunctions.TruncateTime(r.ArrivalDate) && DbFunctions.TruncateTime(LeaveDate) <= DbFunctions.TruncateTime(r.ArrivalDate) || DbFunctions.TruncateTime(ArrivalDate) >= DbFunctions.TruncateTime(r.LeaveDate) )).ToList(); ViewBag.StartingDate = ArrivalDate; ViewBag.EndingDate =

How do I post back data from a partial view in MVC?

故事扮演 提交于 2019-12-25 03:53:59
问题 I have a main view and two partial views Index - main view _Details - partial view _Address- partial view inside the Details partial view Index - main view @model IndexViewModel @{ Layout = "~/Views/Shared/_CodeLayout.cshtml"; } @Html.Partial("_Details", Model) 2. _Details - partial view @model IndexViewModel <div id="Detailsdiv"> @using (Html.BeginForm("_Details", "FS", FormMethod.Post, new { id = "frmFS", @class = "form-horizontal" })) { <div class="row"> <div class="col-lg-1 nopadding">

ASP.NET MVC 5 double value always 0.0 in controller

ぐ巨炮叔叔 提交于 2019-12-25 03:26:43
问题 In my ASP.NET MVC 5 app I have form where user can enter price. Of course that value isn't always integer so I defined it as double in my Model. And when User enter some value, e.g. 10000.00 and press submit, model sent to controller always have 0.0 value for property price. Any ideas why ? My property is defined in model as: [Required(ErrorMessageResourceType = typeof(Resources), ErrorMessageResourceName = "_errorEmpty")] [Display(Name = "_carPrice", ResourceType = typeof(Resources))] public

Dropdown list mvc5 from other model

女生的网名这么多〃 提交于 2019-12-25 03:09:17
问题 First time using MVC to develop an app and have run into an issues populating a dropdown in the student create view with a list of teachers. I have 2 models public class Student { [Required] [Display(Name = "ID")] public int ID { get; set; } [Required] [StringLength(100)] [DataType(DataType.Text)] [Display(Name = "First Name")] public string FirstName { get; set; } [Required] [StringLength(100)] [DataType(DataType.Text)] [Display(Name = "Last Name")] public string LastName { get; set; }

Handle Automapper exception?

ⅰ亾dé卋堺 提交于 2019-12-25 02:46:26
问题 Using mvc5 with automapper I have following: In Controller : [HttpPost] public ActionResult LunchMenu_Create_Index(VmSysMenuCreate menu) { try { var domainMenu = Mapper.Map<VmSysMenuCreate, Menu>(menu); } catch (Exception ex) { return Content("Error msg"); } return Content("Succes"); } Mapping: Mapper.CreateMap<VmSysMenuCreate, Menu>() .ForMember(c => c.Id, op => op.MapFrom(v => v.Id)) .ForMember(c => c.MenuDate, op => op.ResolveUsing(data => { try { DateTime convertedDate = Convert

kendo upload image file dimension validation

对着背影说爱祢 提交于 2019-12-25 02:29:57
问题 here is my problem i have been using ken do-control upload control to upload my images and the real problem is i want to set validation that user should upload image in 35 mm*45 mm.and in ken do upload events i have given a function Events(events => .Select("onImageSelect") and in function function onImageSelect(e) { if (e.files[0].width == 35||e.files[0].height == 45) { return true; } but i am getting width and height undefined 来源: https://stackoverflow.com/questions/24076714/kendo-upload

The right compromise between “browser speed” and “respecting the model”

三世轮回 提交于 2019-12-25 02:29:17
问题 I've been creating a Google Maps API MVC5 application for the past weeks. I know that I should keep all the logic inside the controller, but I have the following doubt: In my main View I have a button called "Avoid tolls". By pressing that button the user will see the route distances calculated previously in the controller (both with and without tolls). My question is: Why should I get the route's distances in the controller (xml service) with and without tolls when I could do that inside the