0
<select id="TypeOfUser" name="typeOfUser" class="active text-normal">
<option value="2" onclick="location.href='@(Url.Action("Index", "User", new { typeOfUser = 2}))'">CMS Users</option>
<option value="3" onclick="location.href='@(Url.Action("Index", "User", new { typeOfUser = 3}))'">Site Users</option>
</select>
在下拉菜单项目的选择我想打电话给我的操作方法与选择的值 -如何使用Razor视图
public async Task<IActionResult> Index([FromQuery] int typeOfUser = 2)
{
SearchUsersResponse searchUserResponse = await new SearchUsersHandler(_db).Handle(new SearchUsersCommandAsync
{
Type = typeOfUser
});
return View("Index", searchUserResponse);
}
目前在下拉选择改变我不能呼吁下拉菜单选择操作方法调用操作方法。
您已经使用JavaScript(你觉得呢'onclick'是) –
AFAIK,选择元素将无法调用任何操作方法本身没有事件触发,你需要设置由JS onchange事件/ jQuery并提交更改后的值以将其作为控制器端的参数值传递。 –