![]() |
|
|
|||||||
![]() |
ASP Net - problem with defaultbutton cross browser |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
I have a problem making a deafultbutton that works cross browser, I tried
setting a defaultbutton on a panel, but that diden't work in Firefox. I have also tried to use som java-script: I have added a "onkeydown" event to the textbox that shall belon to a certain button <script type="text/javascript" language="JavaScript1.2"> function defaultButtonFunktion(evt, btn) { var keyCode = evt.which ? evt.which : evt.keyCode; if (keyCode == 13) { evt.returnValue=false; evt.cancel = true; btn.click(); } } </script> This also dossen't work in FireFox. What do I do? Thanks in adavance PNR |
|
|
|
|
#2 |
|
Posts: n/a
|
On Nov 4, 8:36*am, PNR <P...@discussions.microsoft.com> wrote:
> I have a problem making a deafultbutton that works cross browser, I tried > setting a defaultbutton on a panel, but that diden't work in Firefox. I have > also tried to use som java-script: > I have added a "onkeydown" event to the textbox that shall belon to a > certain button > > <script type="text/javascript" language="JavaScript1.2"> > > * * * * function defaultButtonFunktion(evt, btn) { > * * * * * * var keyCode = evt.which ? evt.which : evt.keyCode; > * * * * * * if (keyCode == 13) { > * * * * * * * * evt.returnValue=false; > * * * * * * * * evt.cancel = true; > * * * * * * * * btn.click(); > * * * * * * } > * * * * } > * * </script> * > > This also dossen't work in FireFox. > > What do I do? > > Thanks in adavance Looks like your code is correct. At least, for me it works in IE and FF <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1" %> <!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></title> <script type="text/javascript" language="JavaScript1.2"> function defaultButtonFunktion(evt, btn) { var keyCode = evt.which ? evt.which : evt.keyCode; if (keyCode == 13) { evt.returnValue = false; evt.cancel = true; btn.click(); } } </script> </head> <body onkeydown="defaultButtonFunktion(event,document.ge tElementById('< %=Button2.ClientID %>'))"> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" /> <asp:Button ID="Button2" runat="server" Text="Button" /> <asp:Button ID="Button3" runat="server" Text="Button" /> </div> </form> </body> </html> Alexey Smirnov |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Browser stops working but Internet still connected | DP | Windows 64bit | 25 | 04-14-2007 01:06 AM |
| File & Printer Sharing Erratic | msb | Wireless Networking | 3 | 04-04-2006 02:41 AM |
| **>> Speed UP 187%(ave.) Your Computer | Kirk Gregory Czuhai | Computer Information | 2 | 08-18-2004 09:34 PM |
| browser hijacker problem | John D | Computer Support | 3 | 07-29-2004 02:49 PM |
| Re: To Anyone who has Internet Explorer Installed or any other browser (Everybody) | sponge | Computer Security | 6 | 06-27-2003 12:35 AM |