Question

I have created an Ajax Form like:

@using (Ajax.BeginForm("myaction", "mycontroller", new AjaxOptions
        {
            UpdateTargetId = "result",
            HttpMethod = "POST",
            OnSuccess = "success"
        }, new { @id = "myForm" }))
        {
            @Html.ValidationSummary(true)

            <div class="editor-label">
                @Html.LabelFor(model => model.autoadvertfilter.Manufacturer)
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(model => model.autoadvertfilter.Manufacturer, (SelectList)ViewBag.Mfr, "--Select--")
                @Html.ValidationMessageFor(model => model.autoadvertfilter.Manufacturer)
            </div>

        <p>
            <input type="submit" value="Go" />
        </p>
        }

When I submit this form, it resets. I want this form to keep the values even after successful submission. Any suggestions would be appreciated.

Was it helpful?

Solution

You can use TempData to store the values in session, just as you do when you are doing server validation of the form without ajax.

http://www.codeproject.com/Articles/476967/WhatplusisplusViewData-2cplusViewBagplusandplusTem

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top