473,385 Members | 1,569 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Enter key to invoke button event handler?

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+PnB boIsL2pjTbk7MQyuNJ1UOHcfr"
/>

<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('Sea rchText').focus()</SCRIPT>

</form>
</body>
</HTML>
Nov 18 '05 #1
1 2094
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" <x@y.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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+PnB boIsL2pjTbk7MQyuNJ1UOHcfr" />

<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('Sea rchText').focus()</SCRIPT>
</form>
</body>
</HTML>

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Matt | last post by:
<input type="button" onClick="doSomething()"> When the user click HTML button, it will launch doSomething(). But I want the user enter ENTER key, it will have same effect. Please advise....
10
by: mg | last post by:
I want to enter characters in a TextBox in a WebForm, press a Button in the WebForm, and read the characters that were typed into the TextBox from within the Button_Click event handler. The main...
5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
6
by: guoqi zheng | last post by:
In a regular html form, when user press "enter" key, the form will be submitted. However, in ASP.NET web form, a form will only be submitted (post back) when a special button is clicked. Many...
6
by: Andrew Willett | last post by:
I have a web form that is a child of a Master Page. It is a login form for forms authentication. When you fill in the username and password box and press ENTER it doesnt process any of the...
12
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items...
15
by: Adam J. Schaff | last post by:
I have noticed that if a user closes a form via pressing return (either while the OK button has focus or if AcceptButton is set to OK for the form) then the "ENTER" keypress event fires ON THE...
5
by: TS | last post by:
for some reason, it posts to the server, but no click events of any buttons on form fire. the button is the first one on the form. when the focus is inside the textbox, it doesnt' work. if i click...
15
by: Oleg Subachev | last post by:
I need to programmatically invoke from other class Click event of the Button on my Form. Button.OnClick method is protected, not public. How to perform this ? Oleg Subachev
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.