I have a standard Edit scenario with GET and POST, the form has a Save button and a Lookup button that allows the user to lookup a postcode, which fills out the address and returns it in the form fields. The Lookup button posts back to the Edit controller method.
The following isn't real code but demonstrates my problem...
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Edit(int CustomerId, string LookupButton)
{
Customer customer = new Customer();
UpdateModel(customer);
//customer.County = "Hello world!";
return View(customer);
...
}
This code does as expected, just returns the existing form data, however when I uncomment the line that manually changes the County field, those changes don't appear on the form. This has thrown me, because in the form
<%= ViewData.Eval("County") %>
will return "Hello world!" but
<%= Html.TextBox("County") %>
still retains the old value!
<input id="County" name="County" type="text" value="" />
Customer is an EF4 class.
Any help much appreciated.