I have a simple test application:
Model:
public class Counter
{
public int Count { get; set; }
public Counter()
{
Count = 4;
}
}
Controller:
public class TestController : Controller
{
public ActionResult Increment(Counter counter)
{
counter.Count++;
return View(counter);
}
}
View:
<form action="/test/increment" method="post">
<input type="text" name="Count" value="<%= Model.Count %>" />
<input type="submit" value="Submit" />
</form>
Clicking Submit I get such values:
5, 6, 7, 8, ...
With Html.TextBox I expected the same behaviour
<form action="/test/increment" method="post">
<%= Html.TextBox("Count") %>
<input type="submit" value="Submit" />
</form>
but actually got
5, 5, 5, 5.
It seems Html.TextBox uses Request.Params instead of Model?