I have an online form. for example, it asks for a first and last name. When they serve, I send them to a different look. this second view has a few more text fields (password, email address, username), but it also has a first and last name. If they fill out the first form and fill in the first / last name, I want the second form to display these values, since they have already been filled.
in the first form, I put all the filled information in TempData ["entry"]
in the second form I do this check.
if (TempData["entry"] != null)
{
var _model = (AccountInformationModel)TempData["entry"];
ViewData["_firstName"] = _model.NameFirst;
ViewData["_lastName"] = _model.NameLast;
}
return View("Register");
I think, in my opinion, I'm a little confused about how to display this data in a text box. I have it in my opinion, but it does not seem to work.
<div class="editor-label">
@Html.LabelFor(m => m.FirstName)
</div>
<div class="editor-field">
@Html.TextBox("FirstName", ViewData["FirstName"])
@Html.ValidationMessageFor(m => m.FirstName)
</div>
clear line that says ...
@Html.TextBox("FirstName", ViewData["FirstName"])
does not work.
source
share