Answer the question
In order to leave comments, you need to log in
How to use session as database and use ID to display form in EditForm view?
There is an ActionResult for creating and editing a form. The POST method receives the completed NewForm in the controller. I need to use id to get form from session in "EditForm".
public ActionResult CreateForm()
{
return View();
}
[HttpPost]
public ActionResult CreateForm(NewForm model)
{
return Redirect("~/Home/EditForm");
}
public ActionResult EditForm(int id)
{
return View(model);
}
[HttpPost]
public ActionResult EditForm(NewForm model)
{
Response.Write("Success");
return View();
}
@model EditFormApplication.Models.NewForm
@using (Html.BeginForm("CreateForm", "Home", FormMethod.Post)){
@Html.HiddenFor(model => model.ID)
@Html.TextBoxFor(model => model.Name)
@Html.TextBoxFor(model => model.Age)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question