Reputation: 5965
In the what's new in ASP.NET 4.5 doc it talks about model binding in web forms which I'm trying out.
I have some of it working but I'm getting a compile time error:
'System.Web.UI.Control' is not an attribute class
This is pointing to the word Control in this part of the code [Control("ddlCategory")] int? categoryId.
I'm thinking I need to add some reference but the doc doesn't mention that, so I'm not sure what's wrong.
public IEnumerable<Product> LoadProducts([Control("ddlCategory")] int? categoryId)
{
var retval = new List<Product>();
if (categoryId.HasValue)
{
using (var db = new DBDataContext())
{
retval = db.Products.Where(x => x.CategoryId == categoryId.Value).ToList();
}
}
return retval;
}
Upvotes: 1
Views: 793
Reputation: 4994
Try putting the fully-qualified name of the attribute.
So try this:
[System.Web.ModelBinding.Control("ddlCategory")]
Instead of this:
[Control("ddlCategory")]
Upvotes: 4