views:

194

answers:

2

I have following code which only works for first time page is hit. <%= Html.TextBox("Amount",Model.Amount)%>

In above line, debugger shows property calls to get Model.Amount each time the view is being generated. But updated value of Amount is not reflected in generated HTML.

Help

A: 

I presume your form is posting back to itself to change the Amount?

It sounds like the action you are posting to is not doing any work. You'd need to post that source code.

Nik
A: 

I think the problem you are having is probably that the value posted from the form is held in the ModelState and this overrides anything that is directly set as the value for the TextBox in your Action method. This is a 'feature' of the HtmlHelper TextBox extension method. You could either avoid using the built in HtmlHelper method and manually output an input type="text" html element into your form or you could try calling ModelState.Clear() in your action somewhere.

Steve Willcock