Wednesday, 21 August 2013

MVC partial view with int model throws exception

MVC partial view with int model throws exception

I have created a partial view that allows an int to be updated using the
jQuery spinner plugin. This is shown in a qtip tooltip.
@model int
...
@Html.TextBoxFor(x => x, new { @class = "spinner" })
and the controller action:
[HttpGet]
public PartialViewResult TaskPriority(int id)
{
var task = Task.Get(id);
return PartialView("TaskPriority", task.Priority);
}
When I call the action from my page I get:
Value cannot be null or empty. Parameter name: name
The exception is thrown on the TextBoxFor line.
So what am I doing wrong here and why is it wrong? Am I overcomplicating it?

No comments:

Post a Comment