0

我创建了一个 Ajax 表单,例如:

@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>
        }

当我提交此表单时,它会重置。我希望此表单即使在成功提交后也能保留这些值。任何建议,将不胜感激。

4

1 回答 1

0

您可以使用 TempData 将值存储在会话中,就像您在没有 ajax 的情况下对表单进行服务器验证一样。

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

于 2013-09-03T05:16:00.307 回答