Reputation: 103
<div class="display-label">
<%: Html.LabelFor(model => model.Customer) %>
</div>
<div class="display-label">
<%: Html.TextBox("Customer") %>
<%: Html.ValidationMessageFor(model => Model.Customer) %>
</div>
i want this value in the textbox to be Uneditable and i still want it to be acessed in the controller. as i am passing the value there
public ActionResult Create(string Customer)
when am passing it in the label, the error " object is not set to instance" is showing up
here is the post method
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();
}
Upvotes: 1
Views: 621
Reputation: 63512
<%=Html.TextBox("Customer", Model.Customer, new { @readonly = "readonly" }) %>
Upvotes: 3