views:

609

answers:

1

I have an update panel which contains a GridView, inside which is a ButtonField. Whenever I press the button I see Firefox doing two POST's (via Firebug). One gets aborted right away, but does reach the server. This causes problems on my server side code as the command (a copy) gets executed twice.

IE6 and IE8 do not exhibit this behavior.

Anyone know what's causing this or what I can do about it?

I've managed to reproduce the problem to its bare minimum on this page:

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

While making this small version, I noticed that the problem only occurs with ButtonType="Image" and not with ButtonType="Button".

For completeness, the event handler:

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

From here, I found a workaround:

Replacing the ButtonField with a TemplateField containing an ImageButton works around the problem. Good enough for me, but still seems like a bug in either ASP .NET or FireFox.

Matthijs P