2011-06-06 67 views
0

我只在IE6上有问题。通过点击IE6上的回车键提交按钮名称

我有一个页面有几种形式,每个包含一个文本框和一个提交按钮。当我使用.NET MVC时,我需要提交按钮的名称来执行正确的操作。当我点击'Enter'键时,我的行为与Firefox或Chrome上的点击操作(发送字段和按钮名称)相同,但不在IE6中,我只有发送的字段。

那么如何在IE6上点击'Enter'键时发送按钮的名称?

TL/DR: 我需要通过点击 'Enter' 键对IE6不仅

Field=foo 

Chrome和Firefox通过点击或运行良好的POST这个

Field=foo&Search= 

送打'输入'

感谢您的帮助:)

[编辑]添加一个例子:

的源代码

<!-- 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 --> 

这是很简单的,这种形式的结构是,每次我需要一个搜索文本框+页面提交按钮重复。 生成代码时可以很好地打开和关闭表单。

生成的代码

<!-- gestion type operation --> 
<fieldset> 
    <legend>Interface de gestion des Types d'Op&#233;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 --> 

[编辑2]我有我的补充形式

<!--[if IE]><input type="text" style="display: none;" name="RechercheTypeOperation" value="" disabled="disabled" size="1" /><![endif]--> 

,它的工作里面这条线。

+0

请发布您的当前代码。 – Ant 2011-06-06 08:44:40

+1

请停止支持IE6(除非你的老板要求你这样做,并且不想明白IE6需要尽快死掉) – ThiefMaster 2011-06-06 08:56:08

+0

很明显,我没有选择使用IE6:'( – 2011-06-06 09:00:48

回答

1

我认为,你不应该依赖提交按钮的名称,而是创建一个<input type="hidden"与你想要的name(如search)。

提交按钮名称和任何其他输入字段的名称之间确实没有区别,但submit输入字段并不是真正的字段,因此总会有一些工件与此相关。

+0

不,我很抱歉我正在使用MVC和Attribute [AcceptButton(“RechercheTypeOperation”)]来验证我的Action。 – 2011-06-06 09:04:12

+0

好吧,对不起,我真的不知道MVC中的任何事情,但作为一个糟糕的解决方法,您可能会添加隐藏的输入请参阅User-Agent字符串中的IE6。 – Gman 2011-06-06 09:27:42

+0

我已添加此行它正在运行!谢谢:) – 2011-06-06 09:44:58