无论如何,有没有可以使动作链接在下拉菜单中工作的 [英] Is there anyway to make actionlinks work inside a dropdown

查看:54
本文介绍了无论如何,有没有可以使动作链接在下拉菜单中工作的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

反正有这项工作吗?

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

因此,这基本上是一个包含链接的下拉列表.当您单击链接时,它应该像普通的ActionLink帮助器一样直接转到该操作方法.

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.

推荐答案

您可以处理select的change事件以打开链接,如下所示:

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:

javascript:

$('select').change(function(){ window.href = $(this).find(':selected').text();});

这篇关于无论如何,有没有可以使动作链接在下拉菜单中工作的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆