Hello team,
I need an urgent help on this
one. Thought it was a common scenario, but couldn’t find a solution till now
, On my web application, I have 2 update panels on a
page having 1 submit button each. ‘Enter’ key was creating issues on firefox,
this was fixed using the following code. (thanks to asp.net forum).
(have created a new page with
only the relevant code to make it easier to understand)
Aspx
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
>
<head runat="server">
<title>Untitled
Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Height="137px" Width="125px" DefaultButton="ImageButton1">
<asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" OnClientClick="this.disabled=true;__doPostBack(this.name,'');"/>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel2" runat="server" Height="173px" Width="155px" DefaultButton="ImageButton2">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" OnClick="ImageButton2_Click" OnClientClick="this.disabled=true;__doPostBack(this.name,'');"/>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
Aspx.cs
protected void ImageButton1_Click(object
sender, ImageClickEventArgs e)
{
//logic for the first button
}
protected
void ImageButton2_Click(object sender, ImageClickEventArgs
e)
{
//logic for the second button
}
This works fine in both IE
and firefox. When ever ‘Enter’ key is pressed within the panel, the correct
button event is getting triggered.
Now one client side
validation is needed for TextBox2, the value shouldn’t be null. I tried many
ways, calling it inside OnClientClick as
the first statement. It works for the first time by showing the alert message. After
that on entering value in TextBox2 and pressing Enter Key it goes to the first
button again :([
Any help is appreciated.
Thanks in advance,
bins.