本文介绍了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> 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> Add New User</a>更多推荐
MVC @ Url.Action不起作用
发布评论