Is there anyway to make actionlinks work inside a

2019-08-31 02:30发布

Is there anyway to make this work:

<select>
        <option>@Html.ActionLink("View", "View", "Person")</option>
        <option>@Html.ActionLink("Edit", "Edit", "Person")</option>
    </select>

So it's basically a dropdown full of links. When you click a link it should direct to the action method like a normal ActionLink helper.

1条回答
来,给爷笑一个
2楼-- · 2019-08-31 02:40

You can handle the change event of the select to open the links, like this:

html:

<select>
    <option>@Url.Action("View", "View", "Person")</option>
    <option>@Url.Action("Edit", "Edit", "Edit")</option>
</select>

javascript:

$('select').change(function(){ window.href = $(this).find(':selected').text();});
查看更多
登录 后发表回答