[英].NET How to send value of drop down list item with GET
我想在我的操作鏈接中以GET方法發送下拉列表的值。 如何獲取所選值並將其作為參數發送?
@Html.DropDownList(string.Format("User_{0}", item.UserID), ListProvider.GetRoles(roleId), new { })
@Html.ActionLink("Set", "UpdateRole", "Admin", new { userId = item.UserID, roleId = roleId }, null)
您應該使用@Html.BeginForm
而不是Action Link進行此類GET請求。
在這種情況下,表單將自動為您構建所有需要的參數。
采用
@using (Html.BeginForm("Set", "UpdateRole", new { area="Admin", userId = item.UserID, roleId = roleId }, FormMethod.Get))
{
@Html.DropDownList(string.Format("User_{0}", item.UserID), ListProvider.GetRoles(roleId), new { })
}
要么
@using (Html.BeginForm("Set", "UpdateRole", new { area="Admin"}, FormMethod.Get))
{
@Html.Hidden("userId", item.UserID);
@Html.Hidden("roleId", roleId);
@Html.DropDownList(string.Format("User_{0}", item.UserID), ListProvider.GetRoles(roleId), new { })
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.