开发者

Bind model explicitly

in general,i will use the code below to make binding of Customer model,

[HttpPost]
public ActionResult Create(Customer model)
{
  ...
}

now, i want to raise the binding la开发者_如何学JAVAter , not immediately ,like this

[HttpPost]
public ActionResult Create()
{
  //some operations first
  ...
  //binding will start here 
  var model={Bind - To - Customer}
  ...
}

so,how can i achieve that, is it possible ???

Thank much for any suggest


You could use the UpdateModel or TryUpdateModel methods:

[HttpPost]
public ActionResult Create()
{
    //some operations first
    ...
    // binding will start here 
    var model = new Customer();
    UpdateModel(customer);
    ...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜