model-binding

MVC 3 AJAX Post, List filled with Objects, but Objects Properties are Empty

随声附和 提交于 2019-12-12 07:26:36
问题 I have the following problem: On a Button-Click I POST some data to the server. My controller Action looks like this: public ActionResult Accept(List<MyViewModel> entries) { //here entries HAS 2 MyViewModel-Instances in it. //The entries are not null, but the values of the instances are! //entries[0].ParamA is null } Where the MyViewModel looks like this: public class MyViewModel { public string ParamA { get; set; } public string ParamB { get; set; } } And the AJAX-Call is the follwing: var

ASP.Net MVC 3 - JSON Model binding to array

心不动则不痛 提交于 2019-12-12 07:10:42
问题 I am on ASP.Net MVC 3, and going by the feature list supported in at, i should be able to get default json model binding working out of the box. However i havent been successful in binding an array/collection from json to the action method parameter. Although I did get simple json object binding working right. Would greatly appreciate if an expert here could tell me what i am doing wrong. Here is the code: Server side code first: //Action Method public JsonResult SaveDiscount(IList<Discount>

Issue with Binding a List of complex type object - Dotnet Core 2.1 Razor Pages

北战南征 提交于 2019-12-12 06:48:02
问题 I'm using Razor pages for my project on dotnet core 2.1, and the application doesn't seem to bind my properties correctly, the simple types (int and string types) binds correctly but not the list of complex types, is there a work around for this? my page handler looks like this: public async Task<IActionResult> OnGetDTResponseAsync(DataTableOptions options) {// Some Code} When I step through with my debugger all simple type properties for "DataTableOptions options" are well populated but the

Detail page of split app without model

帅比萌擦擦* 提交于 2019-12-12 05:49:14
问题 In my split app the detail view does not bind any model. In the component.js I instantiate a named model like this: // creation and setup of the oData model var oConfig = { metadataUrlParams: {}, json: true, defaultBindingMode : "TwoWay", defaultCountMode : "Inline", useBatch : false } // ### tab-employee ### var oModelEmpl = new sap.ui.model.odata.v2.ODataModel("/sap/opu/odata/sap/EMP_SRV"), oConfig); oModelEmpl.attachMetadataFailed(function() { this.getEventBus().publish("Component",

ASP.NET MVC 4 property-renaming for posting

限于喜欢 提交于 2019-12-12 03:34:15
问题 Follwing convention(s) are given. Each Action has a single parameter of type BaseRequest with data depending on the Action . The ViewModel is always of type BaseResponse . What I'm trying to do is, that if a View contains a form, the POST -Action requires some sort of BaseRequest . How can I achieve correct-model binding as of the ViewModel is BaseResponse ? I already tried to add a property of XYZRequest in XYZResponse so I could bind like @Html.ChecBoxFor(m => m.RequestObject

KendoUI grid does not fire saveChanges event ( System.MissingMethodException: Cannot create an instance of an interface.)

折月煮酒 提交于 2019-12-12 02:57:21
问题 KendoUI grid does not fire SaveChanges event. I did not see any problem in Environment of Visual Studio 2013 and browsers(FF, IE, Chrome) when I run the project and clicked on SaveChanges button but SaveChanges event does not fire. For further investigation, I've used debugger of Chrome and I saw a problem. Please see the pictures of problem, error log and codes. (I've used JQuery v1.10) Please help me to solve it. EDITED: I understood that error has related with [Bind(Prefix = "models")]

ASP.NET MVC: types cast in model binding

送分小仙女□ 提交于 2019-12-11 19:29:52
问题 Is there a way to cast parameter in the controller's action from one type to another in ASP.NET MVC 5? Example. Action method is the following: public string Test(Guid input) { return ""; } If the method is invoked with parameters "input=hello" then I get the error with the message: "The parameters dictionary contains a null entry for parameter 'input' of non-nullable type 'System.Guid' for method 'System.String Test(System.Guid)' in 'RealtyGuide.WebSite.Controllers.HomeController'. An

Model Binding with variable number of items in List<T>

做~自己de王妃 提交于 2019-12-11 17:10:07
问题 I have a model that can have a variable amount of items in a List<T> In my view I then have the following: @using (Html.BeginForm()) { int count = Model.Data.Filters.Count; for(int i = 0; i < count; i++) { <div> @Html.TextBox("filtervalue" + i) @Html.DropDownList("filteroptions"+i,Model.Data.Filters[i].FilterOptions) </div> } @Html.Hidden("LinkID", Url.RequestContext.RouteData.Values["id"]) } Is there a way in my controller so I can set up the POST action method to bind to a model with

Update Table via Binding Model in ASP .Net Core 2.2

拥有回忆 提交于 2019-12-11 17:06:40
问题 I want to change creating table conditions like this: There is a way of creating table via list model. My aim, when input a number in Determine Number Text Box, then the table will change according to Determine Number. Example: If DetermineNumber is 5, then the table's row is 5 and the structure of this table will be same like older (A column 0 and B column 0++). Here is my code: //My Home Controller using Microsoft.AspNetCore.Mvc; using MyWeb.Models; using System.Collections.Generic;

Tell modelbinding that MVC action parameter is JSON

此生再无相见时 提交于 2019-12-11 14:22:18
问题 I am using an upload control to send a file to a JsonResult, but I am also sending up a JSON string as a second parameter. This is all getting posted with the Content-Type:multipart/form-data; [HttpPost] public JsonResult UploadDocument(HttpPostedFileBase file, DocumentViewModel model) { ... } I know MVC is capable of binding directly to a viewmodel if the content type is set to application/json but I don't think it's possible for me to set that in this case. Is there any way for me to get