Go Back   Velocity Reviews > Newsgroups > ASP Net
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

ASP Net - problem with defaultbutton cross browser

 
Thread Tools Search this Thread
Old 11-04-2009, 07:36 AM   #1
Default problem with defaultbutton cross browser


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
  Reply With Quote
Old 11-04-2009, 09:31 PM   #2
Alexey Smirnov
 
Posts: n/a
Default Re: problem with defaultbutton cross browser
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
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46