This is an example I have lifted here: http://aspalliance.com/1776_ASPNET_MVC_Beta_Released.5
public ActionResult Save(int id)
{
Person person = GetPersonFromDatabase(id);
try
{
UpdateMode<IPersonFormBindable>(person)
SavePersonToDatabase(person);
return RedirectToAction("Browse");
}
catch
{
return View(person)
}
}
interface IPersonFormBindable
{
string Name {get; set;}
int Age {get; set;}
string Email {get; set;}
}
public class Person : IBindable
{
public string Name {get; set;}
public int Age {get; set;}
public string Email {get; set;}
public Decimal? Salary {get; set;}
}
This will not map values to property Salary but will execute its validation attributes which is not expected when you do the standard [Bind(Exclude="Salary")]
[Bind(Exclude="Salary")]
public class Person
{
public string Name {get; set;}
public int Age {get; set;}
public stiring Email {get; set;}
public Decimal? Salary {get; set;}
}
How will I implement the [Bind(Exclude="Property")] using this interface pattern?