我正在使用 MVC3 和 Razor 视图,我的视图填充了正确的数据
辅助模型
public partial class Visibility
{
public enum VisibilityLevel { ShowThis, HideThis, HideAll }
...
}
public partial class Address
{
public Visibility.VisibilityLevel Visibility{
get {
...
看法
@Html.RadioButtonFor(m => m.HIDE_DATA, Models.Visibility.VisibilityLevel.ShowThis ) <span>Show @Model.TYPE_DESC address</span><br />
@Html.RadioButtonFor(m => m.HIDE_DATA, Models.Visibility.VisibilityLevel.HideThis) <span>Don't show @Model.TYPE_DESC address </span><br />
@Html.RadioButtonFor(m => m.HIDE_DATA, Models.Visibility.VisibilityLevel.HideAll) <span>Don't show ANY addresses</span><br />
控制器
//
// POST: /Address/Edit/5
[HttpPost]
public ActionResult Edit(Address addr,string submitButton)
{
...
这会根据数据和模型定义正确填充页面,但是回发不会获得新值。当我检查控制器时,提交时传递的地址模型具有 RadioButton 的原始值,而不是用户选择或更改的值。我错过了什么?