Html.TextBoxFor不显示在POST操作更新值 [英] Html.TextBoxFor does not show updated value in POST action

查看:189
本文介绍了Html.TextBoxFor不显示在POST操作更新值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我看来,我有

      <%:Html.LabelFor(model => model.IPAddress)%>

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

在我的控制器(POST方法),我有这样的

In my controller(post method), I have this

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

所以,我的问题是:
当我改变模式,TextBoxFor不会改变他的价值。
TextBoxFor得到他的价值,当我从get方法得到的帖子,后来我改变不了TextBoxFor的价值。
我调试,和我的模型有新的价值,但TextBoxFor不显示新的价值。

So, my question is: When I change model, the TextBoxFor does not change his value. TextBoxFor get his value when I get from get method to the post, and later I cannot change value of TextBoxFor. I debug, and my model have new value, but TextBoxFor does not show new value.

你能帮助我吗?

推荐答案

尝试:

ModelState.Clear();
return View(model);

如果不是的结果!返回JSON结果,然后由JavaScript更新

If not result! return a JSON Result and then update by javascript

这篇关于Html.TextBoxFor不显示在POST操作更新值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆