问题
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