MVC4 Html.BeginForm submit button in internet Explorer >9 not working

我是研究僧i 提交于 2019-12-11 20:43:43

问题


I have a form written in ASP.NET MVC4/Razor. The form post works perfectly well in Firefox and Chrome, but for some reason in Internet Explorer 10 and 11, the "Submit" button is unresponsive. (Internet Explorer 9 works also good).

This is how my form in the view looks like:

<div class="bla">
    <table style="width:100%;">
    @using (Html.BeginForm("MyAction","MyController", FormMethod.Post, new        {id="myID"}))
    {
       <thead>
            <tr>
                <th class="heading highlight">Enter Registration</th>
                <th>
                    <span style="display: block;">
                        @Html.EditorFor(model => model.Sign)
                        <input style="margin-left:4px;" type="submit" value="Save" />
                    </span>
                    <span style="display: block; font-weight: normal;">@(Model.SignDescription)</span>

                </th>
            </tr>
        </thead>
    }
    </table>
</div>

And this is my Controller:

[HttpPost]
public ActionResult MyAction(InfoModel infoModel)
{
     if(!string.IsNullOrEmpty(infoModel.Sign))
     {
            //do something
     }

     infoModel = LoadModel ();

     return (indoModel);
}

I really have no idea why this is happening...

THanks in Advance!

EDIT: My form is inside a table, I forgot to add it..


回答1:


Your markup is invalid - form element cannot be child of table element. Rearrange your markup so @using (Html.BeginForm( will be inside <th> .




回答2:


you don't need to Write 'Mycontroller' complete try writing with prefix only in form.




回答3:


Also ensure that your users haven't disabled JavaScript. I spent the last 2 days trying to work out why this didn't work on IE8, but was fine on other browsers. I even had to build a windows XP hyper-v installation, just to try and reproduce the issue!



来源:https://stackoverflow.com/questions/24077308/mvc4-html-beginform-submit-button-in-internet-explorer-9-not-working

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