MVC3编辑器没有填充Chrome

时间:2012-08-21 21:56:51

标签: asp.net-mvc-3 google-chrome razor

我在创建视图中填充文本框时遇到问题。相关代码如下。

型号:

public class Client
{
    public int ClientID { get; set; }
    private string _username = HttpContext.Current.User.Identity.Name;
    public string UserName 
    {
        get
        { return _username; }
         set
        { _username = value;}
    }

}

查看:

@model model.Client
<div class="editor-label">
@Html.LabelFor(model => model.UserName)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.UserName)
@Html.ValidationMessageFor(model => model.UserName)
</div>

控制器:

public ActionResult Create()
{
    return View(new Client());
}

这在IE和Firefox中完美运行;呈现<input>文本框,其值设置为当前用户的登录名。但是,在Chrome中,该值为空字符串。

任何人都可以解释这种行为并提供解决方法吗?

提前感谢您的任何帮助。

1 个答案:

答案 0 :(得分:0)

尝试使用Html.TextBoxFor而不是EditorFor?

相关问题