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"> </td>
</tr>
</table>
</td>
<td vAlign="top" bgColor="#e9e9e9">
<table cellSpacing="0" cellPadding="1" width="100%" border="0">
<tr>
<td width="5"> </td>
<td><br>
<H2>Adressesøk</H2>
<P><input name="SearchText" type="text" value="Kvennberggata"
id="SearchText" />
<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"> </td>
</tr>
</table>
</td>
<TD vAlign="top" width="1" bgColor="#212148"></TD>
</tr>
</table>
</td>
</tr>
<tr>
<td bgColor="#212148"> </td>
</tr>
</table>
<SCRIPT
language="javascript">document.getElementById('SearchText').focus()</SCRIPT>
</form>
</body>
</HTML>
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"> </td>
</tr>
</table>
</td>
<td vAlign="top" bgColor="#e9e9e9">
<table cellSpacing="0" cellPadding="1" width="100%" border="0">
<tr>
<td width="5"> </td>
<td><br>
<H2>Adressesøk</H2>
<P><input name="SearchText" type="text" value="Kvennberggata"
id="SearchText" />
<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"> </td>
</tr>
</table>
</td>
<TD vAlign="top" width="1" bgColor="#212148"></TD>
</tr>
</table>
</td>
</tr>
<tr>
<td bgColor="#212148"> </td>
</tr>
</table>
<SCRIPT
language="javascript">document.getElementById('SearchText').focus()</SCRIPT>
</form>
</body>
</HTML>