I have a problem on IE6 only.
I have a page with several forms, each contains a textbox and a submit button. As I’m using .NET MVC, I need the name of the submit button to execute the correct Action. When I’m hitting ‘Enter’ key, I have the same behaviour as a clicked action on Firefox or Chrome (Field and ButtonName is sent), but not in IE6, where I have only the field that sent.
So how to send the name of the button when I’m hitting ‘Enter’ key on IE6 ?
tl/dr :
I need to send in POST this
Field=foo&Search=
by clicking the ‘Enter’ key on IE6 and not only
Field=foo
Chrome and Firefox works well by clicking or hitting ‘Enter’
Thanks for helping 🙂
[EDIT] Add an example:
Source code
<!-- gestion type operation -->
<fieldset>
<legend>Interface de gestion des Types d'Opérations</legend>
<% Html.BeginForm("TypeOperation", "Administration", FormMethod.Post); %>
<%= Html.EditorFor(m => m.TypeOperationField)%>
<input type="submit" id="RechercheTypeOperation" name="RechercheTypeOperation" value=""
class="loupe" />
<% Html.RenderPartial("ListeTypeOperation", Model); %>
<% Html.EndForm(); %>
</fieldset>
<!-- gestion type operation -->
It is pretty simple, this form struct is repeated each time I need a search textbox + submit button in page.
Forms are well opened and closed when the code is generated.
Generated Code
<!-- gestion type operation -->
<fieldset>
<legend>Interface de gestion des Types d'Opérations</legend>
<form action="/Administration/TypeOperation" id="form3"
method="post">
<input class="text-box single-line" id="TypeOperationField"
name="TypeOperationField" type="text" value="" />
<input type="submit" id="RechercheTypeOperation"
name="RechercheTypeOperation" value="" class="loupe" />
<div>
<table class="grid">
<thead>
<tr>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</form>
<script type="text/javascript">//
<![CDATA[
if (!window.mvcClientValidationMetadata) { window.mvcClientValidationMetadata = []; }
window.mvcClientValidationMetadata.push({"Fields":[],"FormId":"form3","ReplaceValidationSummary":false});
//]]>
</script>
</fieldset>
<!-- gestion type operation -->
[EDIT 2] I have add this line inside my form
<!--[if IE]><input type="text" style="display: none;" name="RechercheTypeOperation" value="" disabled="disabled" size="1" /><![endif]-->
And it’s working.
I think, you shouldn’t rely on the name of submit button, but rather create an
<input type="hidden"with thenameyou want (likesearch).There’s really no difference between submit button name and the name of any other input field, except that
submitinput field is not really a field, so there always could be some artifacts with that.