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