jquery
  • asp.net-mvc
  • jquery-ui
  • 2013-12-12 203 views 0 likes 
    0

    我在我的共享/ _layout.cshtml中使用jqueryui按钮作为登录按钮。以下是点击事件的代码。点击按钮后,我希望将用户转移到帐户控制器的登录视图。jqueryui button click not working with url.action

    $("#btnSignIn").click(function() { 
          //alert("This is button on click event."); 
          top.location.href = '<%= Url.Action("Logon", "Account"); %>' 
         }); 
    

    调试时,出现以下错误。我已经在SO寻找帮助。 enter image description here

    回答

    2

    这很奇怪。如果它是你的_layout.cshtml,那么你正在使用剃刀。

    对于剃须刀,它应该是:

    $("#btnSignIn").click(function() { 
         //alert("This is button on click event."); 
         top.location.href = '@Url.Action("Logon", "Account")'; 
    }); 
    
    +0

    我很新的MVC,还在身边工作我的方式与语法。感谢您的解决方案。 – Purusartha

    相关问题