Defaultbutton handling misbehaving in firefox after hitting back button

  • Thread starter Thread starter gferreri
  • Start date Start date
G

gferreri

Hi all,

I've stumbled on an interesting problem with the way Firefox handles
form submitting with the enter key.

I'm putting together a page that has one form element with multiple
controls with their own textbox field and submit imagebuttons. I've
set up each control in an asp:Panel with their DefaultButton property
set to the proper button, so when the enter key is pressed, the proper
button event handler is triggered. This works in every case EXCEPT
when i submit the form in firefox, hit the back button, and hit enter
in the second text box. Firefox never calls the
WebForm_FireDefaultButton handler, and the server responds as though
the other button was clicked.

I'm thinking this has to do with the page caching that firefox
introduced with 1.5, but I have no clue how to work around this. Any
suggestions? Has anyone else seen this behavior?
 
Here's a simple example:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs"
Inherits="test" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="Panel1" runat="server"
DefaultButton="testButton1">
<asp:TextBox ID="TextBox1" runat="server" MaxLength="10" />
<asp:Button ID="testButton1" Text="Button 1" runat="server"
OnClick="testButton1_Click" />
</asp:Panel>
<asp:Panel ID="testPanel" runat="server"
DefaultButton="testButton2">
<asp:TextBox ID="testTextBox" runat="server" MaxLength="10"
/>
<asp:Button ID="testButton2" Text="Button 2" runat="server"
OnClick="testButton2_Click" />
</asp:Panel>
<asp:Label ID="Label1" runat="server" />
</div>
</form>
</body>
</html>

Codebehind:
public partial class test : System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {

}
protected void testButton1_Click(object sender, EventArgs e) {
this.Label1.Text = "Button 1 Clicked";
}
protected void testButton2_Click(object sender, EventArgs e) {
this.Label1.Text = "Button 2 Clicked";
}
}
 
Back
Top