如何在MVC-4中使用IsPostBack

时间:2014-09-08 12:14:05

标签: asp.net-mvc asp.net-mvc-4 postback

如果表单状态回发,我想不绑定我的下拉列表。正如您在我的代码中看到的,我有两个表单和两个提交按钮。单击第二个提交按钮后,我想保留下拉列表的选定值。

   <form method="POST" action="@Url.Action("UserRoles", "PageUserRole")">
                <label>Kullanıcı Grubu</label>
                @Html.DropDownList("Id",  Utility.GetUserGroups(), "Kullanıcı Grubu Seçiniz.")
                &nbsp;<input type="submit" value="Listele" />
            </form>

...

<form method="POST" action="@Url.Action("EditUserRoles", "PageUserRole")">
            <table>
                <tbody>
                    <tr>
                        <td>
                            İşlem
                        </td>
                        <td>
                            Yetki
                        </td>
                    </tr>
                    @for (int i = 0; i < Model.PageMenUsuserRoles.Count; i++)
                    {
                        <tr>
                            <td>
                                @Model.PageMenUsuserRoles[i].pagemenu.Name

                            </td>
                            <td>
                                @Html.Hidden("PageMenUsuserRoles[" + i + "].Id", Model.PageMenUsuserRoles[i].Id)
                                &nbsp; @Html.CheckBox("PageMenUsuserRoles[" + i + "].CanView", Model.PageMenUsuserRoles[i].CanView)
                            </td>
                        </tr>
                    }
                    <tr>

                        <td colspan="2">
                            <input type="submit" value="Kaydet" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>

0 个答案:

没有答案