asp.net-mvc – Html.TextBoxFor在POST操作中不显示更新的值

前端之家收集整理的这篇文章主要介绍了asp.net-mvc – Html.TextBoxFor在POST操作中不显示更新的值前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
在我看来,我有
<%:Html.LabelFor(model => model.IPAddress)%>

    <div class="editor-field">
        <%:Html.TextBoxFor(model => model.IPAddress)%>
        <%:Html.ValidationMessageFor(model => model.IPAddress)%>
    </div>

在我的控制器(post方法)中,我有这个

[HttpPost]
public ActionResult Manipulation(MyModel model){
  //I change modele here
  if(somthing)
    model.IPAddress="100.100.100.100";
  return View(model);
}

所以,我的问题是:
当我更改模型时,TextBoxFor不会更改其值.
当我从get方法到帖子时,TextBoxFor得到他的值,后来我无法改变TextBoxFor的值.
我调试,我的模型有新值,但TextBoxFor没有显示新值.

你能帮助我吗?

解决方法

尝试:
ModelState.Clear();
return View(model);

如果不是结果!返回JSON结果,然后通过javascript更新

原文链接:https://www.f2er.com/aspnet/248741.html

猜你在找的asp.Net相关文章