S
S
Sergey Korolkov2019-02-07 20:06:16
ASP.NET
Sergey Korolkov, 2019-02-07 20:06:16

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();
    }

CreateForm view where id i will generate
@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)
}

It's the same in edit view.
those. in short, I need to emulate the session saving and reading from the database. Select the required data by id

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question