model-binding

GridView SelectMethod Issue With WebPart Sharepoint 2013

夙愿已清 提交于 2019-12-02 07:34:23
Hi every one , I have a problem with a gridview in webpart sharepoint 2013 ,I use model bind with the gridview and I have assigned a select method to the gridview when I deployed the webpart it raise the following error A public method with the name was either not found or there were multiple methods with the same name on the type x.master thanks alot I have found the solution , you need to register this code within the CallingDataMethod GridView event : protected void GridView1_CallingDataMethods(object sender, System.Web.UI.WebControls.CallingDataMethodsEventArgs e) { e.DataMethodsObject =

MVC Model Binding Not Working via AJAX request

微笑、不失礼 提交于 2019-12-02 07:20:29
问题 Having a little trouble with MVC model binding via AJAX. Can someone tell me why the CreateTransfereeDetails property is not binding, it always comes back as 'null'. Model: public class ResolveProfileSelectionRequiredModel { public CreateTransfereeModel CreateTransfereeDetails { get; set; } public bool NewTransfereeSelected { get; set; } } public class CreateTransfereeModel { [Display(Name = "Transferee Name:")] public string TransfereeName { get; set; } } Html: <input type="text" id=

WebApi - action paramer is null when using [FromBody] attribute and POST method

眉间皱痕 提交于 2019-12-02 06:16:07
问题 I have this controller and I can't figure out, why name parameter is null public class DeviceController : ApiController { [HttpPost] public void Select([FromBody]string name) { //problem: name is always null } } here is my route mapping: public void Configuration(IAppBuilder appBuilder) { HttpConfiguration config = new HttpConfiguration(); config.Routes.MapHttpRoute( name: "ActionApi", routeTemplate: "api/{controller}/{action}" ); appBuilder.UseWebApi(config); } and here is my request: POST

Consume jQuery.serializeArray in ASP.NET MVC

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-02 05:36:00
I post $('#myForm').serializeArray() to an ASP.NET MVC (2.0) action. serialized array looks as follows: filters[0][name] : gemcolor filters[0][value] : Yellow filters[1][name] : gemcolor filters[1][value] : Green filters[2][name] : jcOnly filters[2][value] : true someOtherData : abc I want to have that consumed in: public ActionResult GetData(Filter filter) class Filter { string someOtherData; bool jcOnly; List<string> gemcolor; } I can just dig through FormCollection , but I am looking for a more elegant solution (I suspect it will involve a custom model binder). Darin Dimitrov This won't

MVC2 RTM - model binding complex objects using Entity Framework

百般思念 提交于 2019-12-02 04:16:07
I am new to MVC, and am really struggling with what I seems like it should be a very common scenario. I'm using MVC2 RTM, and the Entity Framework for my model objects. What I have working: An edit view for a parent object that contains a collection of child objects. The form displays all the editable fields for the parent, and iterates through and displays all editable fields for all the associated child objects (in the same view). I am able to successfully handle the edit action in my controller, but run into issues when I try to bind values in the form collection to the EF model objects.

Globalization problem with DateTime and ASP.NET MVC 3 Model Binding

断了今生、忘了曾经 提交于 2019-12-02 03:33:14
问题 My application runs under ro-RO culture settings, configured in web.config globalization section. If I make a POST request like POST /myapp/index date=03-12-2010&value=something the model binding maps this to correct date value of "03 December 2010", since the default datetime format for ro-RO culture is dd-MM-yyyy. If I change the request method to GET passing the same data the date value in my action becomes "12 March 2010" (MM-dd-yyyy datetime format) GET /myapp/index?date=03-12-2010&value

Is it possible to have a non-public parameterless constructor that can be used for model binding?

安稳与你 提交于 2019-12-02 02:56:13
I have a following POCO class. I don not want the parameterless constructor to be public. public class FileDownloadRequest { //public FileDownloadRequest() { } public FileDownloadRequest(int fileId, RepositoryFolderTypes fileType) //RepositoryFolderTypes is an enum, not a class { this.FileId = fileId; this.FileType = fileType; } public int FileId { get; set; } public RepositoryFolderTypes FileType { get; set; } //an enum } When I am trying a https://10.27.8.6/Files/DownloadFile?fileId=1&folderType=SRC request to the following controller action, I get an error saying that no parameterless

MVC Model Binding Not Working via AJAX request

只谈情不闲聊 提交于 2019-12-02 01:16:14
Having a little trouble with MVC model binding via AJAX. Can someone tell me why the CreateTransfereeDetails property is not binding, it always comes back as 'null'. Model: public class ResolveProfileSelectionRequiredModel { public CreateTransfereeModel CreateTransfereeDetails { get; set; } public bool NewTransfereeSelected { get; set; } } public class CreateTransfereeModel { [Display(Name = "Transferee Name:")] public string TransfereeName { get; set; } } Html: <input type="text" id="TransfereeName" /> <input type="hidden" id="NewTrasnfereeSelected" /> JavaScript: var createTransfereeDetails

Globalization problem with DateTime and ASP.NET MVC 3 Model Binding

核能气质少年 提交于 2019-12-01 23:43:30
My application runs under ro-RO culture settings, configured in web.config globalization section. If I make a POST request like POST /myapp/index date=03-12-2010&value=something the model binding maps this to correct date value of "03 December 2010", since the default datetime format for ro-RO culture is dd-MM-yyyy. If I change the request method to GET passing the same data the date value in my action becomes "12 March 2010" (MM-dd-yyyy datetime format) GET /myapp/index?date=03-12-2010&value=something $.getJSON('/Home/Index', $('form').serialize(), function(d) { // ... }); $.post('/Home/Index

How Do I Model Bind A List Of 'List<SelectItem>' Using MVC.Net

末鹿安然 提交于 2019-12-01 23:34:36
问题 I am trying to create a form that will consist of a series of dropdown lists, all of which are loaded from a database. I will not know how many dropdown lists will be needed, or how many options each dropdown list will have at compile-time. How can these fields be set-up to allow them to model-bind when posted? There is a lot of other complexity in each of the below code elements, but I cannot get the model binding to work even when reduced down to a basic level. The Models: public class