Enter key to invoke button event handler?

O

Olav Tollefsen

I have created a client side script that is supposed to invoke the Click
event handler on a button. The problem is that it doesn't work. Instead the
page is refreshed an Page_Load is invoked, but not my event handler. The
source of my .aspx page is included below.

What could the problem be?

Olav

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Adressesøk</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="CSS/Level1_Verdana.css" type="text/css" rel="stylesheet">
<script language="javascript">
function CheckEnterKey()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all["SearchButton"].click();
}
}
</script>
</HEAD>
<body>
<form name="Form1" method="post" action="FindAddress.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwxMTc0MDkyNjQyOztsPFNlYXJjaEJ1dHRvbjs+PnBboIsL2pjTbk7MQyuNJ1UOHcfr"
/>

<table cellSpacing="0" cellPadding="0" width="785" border="0">
<tr>
<td><IMG height="132" src="Images/Top.jpg" width="785"></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="785" border="0">
<tr>
<td vAlign="top" width="160"
background="Images/LeftBackground2.gif">
<table cellSpacing="0" cellPadding="0" width="160" border="0">
<tr>
<td background="Images/LeftBackground1.gif"
height="431">&nbsp;</td>
</tr>
</table>
</td>
<td vAlign="top" bgColor="#e9e9e9">
<table cellSpacing="0" cellPadding="1" width="100%" border="0">
<tr>
<td width="5">&nbsp;</td>
<td><br>
<H2>Adressesøk</H2>
<P><input name="SearchText" type="text" value="Kvennberggata"
id="SearchText" />&nbsp;
<input type="image" name="SearchButton" id="SearchButton"
src="Images/SearchButton.gif" border="0" /></P>
<P>
<div id="Panel1">



<br>

</div>

</P>
<P></P>
</td>
<td width="5">&nbsp;</td>
</tr>
</table>
</td>
<TD vAlign="top" width="1" bgColor="#212148"></TD>
</tr>
</table>
</td>
</tr>
<tr>
<td bgColor="#212148">&nbsp;</td>
</tr>
</table>
<SCRIPT
language="javascript">document.getElementById('SearchText').focus()</SCRIPT>

</form>
</body>
</HTML>
 
A

Alvin Bruney

Have you figured this out, or at least a work around?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
Olav Tollefsen said:
I have created a client side script that is supposed to invoke the Click
event handler on a button. The problem is that it doesn't work. Instead the
page is refreshed an Page_Load is invoked, but not my event handler. The
source of my .aspx page is included below.

What could the problem be?

Olav

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Adressesøk</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<LINK href="CSS/Level1_Verdana.css" type="text/css" rel="stylesheet">
<script language="javascript">
function CheckEnterKey()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
document.all["SearchButton"].click();
}
}
</script>
</HEAD>
<body>
<form name="Form1" method="post" action="FindAddress.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE"
value="dDwxMTc0MDkyNjQyOztsPFNlYXJjaEJ1dHRvbjs+PnBboIsL2pjTbk7MQyuNJ1UOHcfr"
/>

<table cellSpacing="0" cellPadding="0" width="785" border="0">
<tr>
<td><IMG height="132" src="Images/Top.jpg" width="785"></td>
</tr>
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="785" border="0">
<tr>
<td vAlign="top" width="160"
background="Images/LeftBackground2.gif">
<table cellSpacing="0" cellPadding="0" width="160" border="0">
<tr>
<td background="Images/LeftBackground1.gif"
height="431">&nbsp;</td>
</tr>
</table>
</td>
<td vAlign="top" bgColor="#e9e9e9">
<table cellSpacing="0" cellPadding="1" width="100%" border="0">
<tr>
<td width="5">&nbsp;</td>
<td><br>
<H2>Adressesøk</H2>
<P><input name="SearchText" type="text" value="Kvennberggata"
id="SearchText" />&nbsp;
<input type="image" name="SearchButton" id="SearchButton"
src="Images/SearchButton.gif" border="0" /></P>
<P>
<div id="Panel1">



<br>

</div>

</P>
<P></P>
</td>
<td width="5">&nbsp;</td>
</tr>
</table>
</td>
<TD vAlign="top" width="1" bgColor="#212148"></TD>
</tr>
</table>
</td>
</tr>
<tr>
<td bgColor="#212148">&nbsp;</td>
</tr>
</table>
<SCRIPT
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top