Defaultbutton handling misbehaving in firefox after hitting back button

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

Greg

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";
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top