TextBoxFor is not refreshing after postback

Viewed 3120

I'm probably making a stupid mistake somewhere. I would appreciate your help in the following.
I have sample MVC3 application with a single editable field that is displayed to user with TextBoxFor method. In the Index(POST) action I change the value but it still remains the same. What am I doing wrong?

My code:
Model:

public class TestModel
{
    public string Name { get; set; }
}

View:

using (Html.BeginForm())
{
    @Html.TextBoxFor(m => m.Name)
    <input type="submit" />
}

Controller:

public ActionResult Index()
{
    return View("Index", new TestModel() { Name = "Before post" });
}

[HttpPost]
public ActionResult Index(TestModel model)
{
    model.Name = "After post";
    return View("Index", model);
}

If I replace TextBoxFor with TextBox or DisplayTextFor then it works correctly.

1 Answers
Related