我正在尝试实现模型绑定,但是收到一个错误:ModelBindingExecutionContext是一种类型,但是像变量一样使用。这是我的代码: (应指定这是针对ASP.NET Web窗体应用程序而不是MVC)
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.ModelBinding;
protected ActivityBO GetActivity()
{
ActivityBO activity = new ActivityBO();
//IValueProvider provider = new FormValueProvider(ModelBindingExecutionContext);
if (TryUpdateModel(activity, new FormValueProvider(ModelBindingExecutionContext)))
{
return activity;
}
else
{
//Error code will go here.
}
}