The custom binding class needs to inherit form IModelBinder. Here we capture the current request and extract the Form fields individually. Then we can manipulate these fields any way we like.
I've been implementing a custom model binder to handle the data returned from the datatables.net jQuery plugin but am having trouble actually getting to the data as it is being passed back in the request body and my ModelBindingContext only seems to…
My team needs to develop a framework for our company and products using this framework.
One of the requisites is that a product could be customized for a specific client, yet it should be easily updated with another version of the same product (not…
im stuck with this very strange problem.
i have an API Controller named AttendanceController derived from APIControllerFA which is inturn derived from ApiController
here is the code
public class AttendanceController : ApiControllerFA
{
…
I've been following Darin's answer to a question I had on slimming down my controllers and I'm running into problems with this IEntityChangeTracker exception:
An entity object cannot be referenced by multiple instances of…
I got into a issue in Model Binding in Asp.Net MVC. I have view model like below,
public class ArticleViewModel : BaseViewModel
{
public Article art { get; set; }
public List attachments { get; set; }
…
Following this question I was wondering if there is anyway to make MVC model binder only bind elements to a list if there is a value to populate them. For example if have a form with three inputs with the same name and one value isn't entered how do…
I'm having trouble implementing a custom model binder that can bind custom "form fields" to correct array indexes.
Here are my viewmodels:
public class NewOrderViewModel
{
public Guid DeliveryAddressId { get; set; }
public Guid…
I have an Angular client and create a POST request with this body:
{"Name":"example","Currency":"EUR"}
I Use Odata protocol and my Controller is:
[HttpPost, ODataRoute("Templates")]
public IActionResult Insert([FromBody] Template value)
…
I'm trying to write a custom datetime model binder that is used to convert a posted string with format "dd/MM/yyyy" to a valid date on server (server date format is "MM/dd/yyyy". My source code looks like below:
View Model
TestViewModel.cs
namespace…
I have created a custom model binder to work with dates. I am having trouble working with nullable DateTimes.
At present if the DataType of a ViewModel property is set to DataType.Data then the custom model binder is correctly called and produces…
I am building a simple search, sort, page feature. I have attached the code below.
Below are the usecases:
My goal is to pass the "current filters" via each request to persist them particularly while sorting and paging.
Instead of polluting my…
I have API controller that has one Put method
public class ScheduleExecutionsController : ApiController
{
public ScheduleExecutionsResponse Put([ModelBinder(typeof(TestBinder))]ScheduleExecutionsRequest requestInfo)
{
....
…
i have the following entities:
public class Category
{
public virtual int CategoryID { get; set; }
[Required(ErrorMessage = "Section is required")]
public virtual Section Section { get; set; }
[Required(ErrorMessage = "Category…
I'm hoping to get some advice about the best way to share a custom model-binder between MVC and WebAPI. The way I've done it, while functional, seems overly complex, and I'm fairly sure there must be a better way.
I have a hybrid application that's…
I have an action method that accepts the following model - LanguagesViewModel:
public class LanguagesViewModel : ViewModelBase
{
IEnumerable Languages { get; set; }
}
public class LanguageItem
{
[Required]
public int LanguageId {…