MVC @ Url.Action不起作用 [英] MVC @Url.Action not working

查看:78
本文介绍了MVC @ Url.Action不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<div class="col-xs-6 text-right margin-top-x5">
     <div class="adduser pointer" data-url="@Url.Action("Register","Account")"><span class="glyphicons glyphicons-user"></span>&nbsp;Add New User</div>
</div>

在FireBug上我可以看到,但不会执行该操作.

On FireBug i can see but it not going to that action.

<div class="adduser pointer" data-url="/Account/Register">

推荐答案

如果您希望 div 是可点击的,则必须为其提供一些代码,以便用户单击它.

If you want a div to be clickable, you have to give it some code to do something when the user clicks it.

$(function() {
    $("[data-url]").click(function() {
        location.href = $(this).data("url");
    });
}

或者,只需使用锚点即可:

Alternatively, just use an anchor:

 <a class="adduser pointer" href="@Url.Action("Register","Account")">
    <span class="glyphicons glyphicons-user"></span>&nbsp;Add New User</a>

这篇关于MVC @ Url.Action不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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