2010-02-06 26 views
0

我有一個更新面板,其中包含一個GridView,其中是一個ButtonField。每當我按下按鈕,我看到Firefox做兩個POST(通過Firebug)。一會立即中止,但確實到達服務器。這會導致我的服務器端代碼出現問題,因爲命令(副本)會執行兩次。按鈕命令使用FireFox在UpdatePanel內的GridView內ButtonField觸發兩次

IE6和IE8不顯示此行爲。

任何人都知道是什麼原因造成的,或者我能做些什麼?

我已經成功地重現該問題在此頁上的最低要求:

<form id="form1" runat="server"> 
<asp:XmlDataSource ID="XmlDataSource1" runat="server"> 
    <Data> 
<bla> 
<wibble wobble="1" /> 
</bla></Data> 
</asp:XmlDataSource> 
<asp:ScriptManager runat="server"></asp:ScriptManager> 
<asp:UpdatePanel runat="server"> 
<ContentTemplate> 

    <asp:Label runat="server" ID="Counter" Text="0"></asp:Label> 
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
     DataSourceID="XmlDataSource1" onrowcommand="GridView1_RowCommand"> 
     <Columns> 
      <asp:BoundField DataField="wobble" HeaderText="wobble" 
       SortExpression="wobble" /> 
      <asp:ButtonField HeaderText="wobble" CommandName="IncrementWobble" 
       SortExpression="wobble" ButtonType="Image" ImageUrl="icons/page_copy.png" Text="increment" /> 
     </Columns> 
    </asp:GridView> 
</ContentTemplate> 
</asp:UpdatePanel> 

</form> 

同時使這個小版本,我注意到,該問題僅出現按鈕類型=「形象」出現,而不是與按鈕類型= 「按鈕」。

爲了完整起見,事件處理程序:

protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) 
{ 
    if (e.CommandName == "IncrementWobble") 
    { 
     int count = Int32.Parse(Counter.Text) + 1; 
     Counter.Text = count.ToString(); 
    } 
} 
+0

我想你將不得不向我們展示一些代碼,以便進一步診斷問題。 – Josh 2010-02-06 18:14:11

+0

提出了該問題的最小代碼示例。 – 2010-02-06 18:43:01

回答

0

here,我發現了一個解決辦法:

包含解決該問題的ImageButton作品TemplateField更換ButtonField。對我來說足夠好,但仍然像ASP .NET或FireFox中的錯誤。

相關問題