<div class="display-label">
<%: Html.LabelFor(model => model.Customer) %>
</div>
<div class="display-label">
<%: Html.TextBox("Customer") %>
<%: Html.ValidationMessageFor(model => Model.Customer) %>
</div>
我希望文本框中的这个值是不可编辑的,我仍然希望它在控制器中被访问。因为我正在传递价值
public ActionResult Create(string Customer)
当我在标签中传递它时,错误“对象未设置为实例”显示
这是post方法
public ActionResult Create(string Customer,string UserName, string Password, string FirstName, string LastName,
string MiddleInitial, string Email,string Telephone, bool IsAdmin, bool IsSubAdmin)
{
UserDAL userDALObject = new UserDAL();
tblUser newUser = new tblUser();
newUser.Customer =Customer ;
newUser.UserName = UserName;
newUser.Password = Password;
newUser.FirstName = FirstName;
newUser.LastName = LastName;
newUser.MiddleInitial = MiddleInitial;
newUser.Email = Email;
newUser.Telephone = Telephone;
newUser.IsAdmin = IsAdmin;
newUser.IsSubAdmin = IsSubAdmin;
userDALObject.AddUserDetails(newUser);
TempData["UserCreationMsg"] = string.Format("User named :{0}, is created",UserName);
return View();
}
答案 0 :(得分:3)
<%=Html.TextBox("Customer", Model.Customer, new { @readonly = "readonly" }) %>