ASP.NET MVC Razor Url.Action doesn't work in Internet Explorer 8

人走茶凉 提交于 2019-12-13 01:47:49

问题


I developed a simple ASP.NET MVC3 project with Razor. Linking between pages, I use the following table:

<table class="indexTable" align="left">
    <tr>
        <td class="indexTd">
        <a class="noUL" href='@Url.Action("Index", "ProblemEntrance")'><button class="menuButton">@ViewBag.ProblemEntrance</button></a>
        </td>

So when I click on ProblemEntrance, it takes me from ProblemEntranceController to ProblemEntrance Index page. Everything works fine in Mozilla and Chrome, but with Internet Explorer, the page just stay the same and doesn't give any reaction to my click. Any idea what I can do about it?


回答1:


Put the href attribute on the button, then hook up a click handler:

<button href='@Url.Action("Index", "ProblemEntrance")' class="menuButton" onclick='location.href=this.getAttribute("href")'>@ViewBag.ProblemEntrance</button>

Heres a fiddle.



来源:https://stackoverflow.com/questions/13696793/asp-net-mvc-razor-url-action-doesnt-work-in-internet-explorer-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!