2011-06-06 68 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