Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET and Firefox: why doesn't clicking on a GridView ButtonField do anything?
    primarykey
    data
    text
    <p>I have a pretty simple ASP.NET Web Form that looks a bit like the following:</p> <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeFile="example.aspx.cs" Inherits="example" %&gt; &lt;form runat="server"&gt; &lt;asp:GridView runat="server" id="grid" AutoGenerateColumns="false" OnRowCommand="DoStuff"&gt; &lt;Columns&gt; &lt;asp:ButtonField Text="Do stuff" /&gt; &lt;/Columns&gt; &lt;/asp:GridView&gt; &lt;/form&gt; </code></pre> <p>(In PageLoad I call <code>grid.DataBind()</code>, and the event handler <code>DoStuff</code> is unremarkable.)</p> <p>When I view this in Internet Explorer and click the ButtonField (which renders as a link), the event handler fires as expected. When I click it in Firefox, nothing happens.</p> <p>If I turn on Firebug's Javascript debugging console then click the link, it shows an error in the Javascript <code>onclick</code> handler that's auto-generated by ASP.NET:</p> <pre><code>theForm is undefined __doPostBack("grid", "$0") javascript:__doPostBack('grid', '$0')() if (!theForm.onsubmit || (theForm.onsubmit() != false)) {\r\n </code></pre> <p>Why does this happen and how can I make the ButtonField work in Firefox?</p> <p>(N.B. I'm asking this question <a href="https://meta.stackexchange.com/questions/17463/is-it-poor-etiquette-to-answer-your-own-question">in order to answer it myself</a>: I've already discovered why I was seeing the above error, and wanted to record it for the benefit of myself and others. Feel free to add other answers if you know other gotchas with ASP.NET and Firefox.)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload