button tag not working in IE7 (using asp.net mvc )

断了今生、忘了曾经 提交于 2020-01-17 01:34:08

问题


I have this ASP.net MVC project that requires a wizard like interface... So I am using the next ,back button inside the form.

And I am trapping the button name in my controller to do the required action.

But the problem is the button click is working in IE8,chrome,ff but not in IE7.

It doesnt seem to fire the postback...do I have to explicity fire the postback on Onclick? Anyone knows why button click not firing in IE7 ???

thanks I appreciate any answer..

Here's the psuedo code I am using...

<% using (Html.BeginForm("ListEntries","Home",FormMethod.Post, new { @Id = "MyForm" } )) {%>
                        <button name="button" value="next">Next</button>
                        <button name="button" value="back">Back</button>
  //blah....blh...blah...


<% } %>

[AcceptVerbs(HttpVerbs.Post)]
    public ActionResult ListEntries( string button)
    {
        if (button == "next")
            return RedirectToAction("doNextAction");
    else
    if (button == "back")
    return RedirectToAction("goBack");

}


回答1:


this link http://www.peterbe.com/plog/button-tag-in-IE makes me believe that in IE7 the button element will not post a single string to your controller so would not match the signature of your controller method, have you tried (as is suggested here) using input elements of type submit instead?

its not something I have seen myself but it seems to match your issue




回答2:


Button tags in IE (v. 8, at least) will not work without an 'onclick' handler. Well, at least you can't simply wrap the button in an anchor tag.

Doesn't work:

<a href="link.html">
    <button>Click Me!</button>
</a>

Works:

<a href="link.html" onclick="javascript:window.location=this.href">
    <button>Click Me!</button>
</a>


来源:https://stackoverflow.com/questions/4937764/button-tag-not-working-in-ie7-using-asp-net-mvc

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