c# - Custom model binding with IModelBinder -
I am trying to write a custom model binder but this is giving an error. Can someone tell me that I Where's the wrong?
using the system; Using System.Collections.Generic; Using System.Data; Using System.Linq; Using System.Web; Using System.Web.Mvc; Namespace MVCs Application 1. Models {Public Class Custom Modibbinder: IMDellBinder {Public Object Bid Module (Controller Contacs Controller Context, Modelbinding Context Binding Contains) {Owned Own = New Ownership (); Own.name = controllerContext.HttpContext.Request.Form ["fName"]; Own.email = controllerContext.HttpContext.Request.Form ["fEmail"]; Myself. Phone no = control console Hpptex request. Farm ["not ffone"]; Own.country = controllerContext.HttpContext.Request.Form ["Country"]; Own.address = controllerContext.HttpContext.Request.Form ["Address"]; Own.office = controllerContext.HttpContext.Request.Form ["Off"]; Own.officeEmail = controllerContext.HttpContext.Request.Form ["OffEmail"]; Own.officeNo = Controlling Consort HttpContext.Request.Form ["No Off"]; Own.OwnershipType = Controlling Consort HttpContext.Request.Form ["OwnershipType"]; Own.ProductId = controllerContext.HttpContext.Request.Form ["ProductId"]; Come back to yourself; }}} error
"custom modellbender 'interface member' system.web.mvc.imodel builder.bind modal (system .com Controller Context, System.vb.mvc.ModelBindingContext)
immodel builder You are using System.Web.ModelBinding namespace. The BindModel method of this interface returns the value of the type of bundle.
bool BindModel (ModelBindingExecutionContext ModelBindingExecutionContext , ModelBindingContext binding contexts) < / Code> If you give the object that you want to use the BindModel method, then you need to apply the interface to the System.Web.Mvc namespace.
You can see this by providing the full namespace when implementing this IMDell Binder interface.
< Pre> object bind modal (controller contact controller context, modelbinding contact binding contax) code> pub la Sense class custom Modebbinder System. Web. MVC Emodelbender {Public Object Bind Module (Controller Contacs Controller Context, Modelbinding Contact Binding Content) {Own Ownership = New Ownership (); Own.name = controllerContext.HttpContext.Request.Form ["fName"]; Own.email = controllerContext.HttpContext.Request.Form ["fEmail"]; Myself. Phone no = control console Hpptex request. Farm ["not ffone"]; Own.country = controllerContext.HttpContext.Request.Form ["Country"]; Own.address = controllerContext.HttpContext.Request.Form ["Address"]; Own.office = controllerContext.HttpContext.Request.Form ["Off"]; Own.officeEmail = controllerContext.HttpContext.Request.Form ["OffEmail"]; Own.officeNo = Controlling Consort HttpContext.Request.Form ["No Off"]; Own.OwnershipType = Controlling Consort HttpContext.Request.Form ["OwnershipType"]; Own.ProductId = controllerContext.HttpContext.Request.Form ["ProductId"]; Come back to yourself; }}
Comments
Post a Comment