473,399 Members | 2,478 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,399 software developers and data experts.

Enter event on control

Hi,

im currently building a web page that incorporates a webcontrol.

on my webcontrol i have a textbox and a button see below

TEXTBOX
<asp:textbox class="mainText" id="txt_QuickSearch" Width="164px"
runat="server"></asp:textbox>

INPUT BOX
<DIV align="right">&nbsp;<INPUT id="img_Search" type="image"
height="12" width="34" src="/wb_WatsonDotNet/Images/titles/search.gif"
name="img_Search" runat="server">

the problem that i am having is that i want to enter details i the
textbox and press enter then it will automatically fire the event on
the input button.

I have tried the 2 following methods but they do not work.

Page.RegisterHiddenField("__EVENTTARGET", "img_Search")

txt_QuickSearch.Attributes.Add("onkeypress", "submitForm(" &
img_Search.ClientID & ");")

Can anyone give me some assistance with this please.
all help appreciated

Jan 5 '07 #1
2 1070
if i understood correctly what you are doing, i think you need to
override createchildcontrols and use the addhandler method

Jan 5 '07 #2
Hello,

you need a little bit javascript:

<HTML>
<HEAD>
<title>TestForm</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<script language=javascript>
function searchImage(img_Search){
if(event.keyCode==13){
event.returnValue=false;
img_Search.click();
}
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:textbox id="txt_QuickSearch" runat="server"
onkeydown="searchImage(this.nextSibling)"></asp:textbox><input
id="img_Search" type="button" value="search">
</form>
</body>
</HTML>

Regards,
Tim

Jan 5 '07 #3

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....
5
by: Eric | last post by:
Hi All, I'm very experienced in traditional ASP and am new to (am learning) ASP.NET. FYI: I am initially learning ASP.NET with VB.NET to ease the transition for me. I have encountered what I...
5
by: PD | last post by:
The TextChanged event is not being called when I hit the "Enter" key. Yet it does for the "Tab" key. I set a break point in the Page_Load event and the TextChanged event and none of these get...
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...
2
by: chuckdfoster | last post by:
I have a form that with a datagrid with textboxes and a submit button. When the user is in a textbox and they hit enter to try to go to a different line, instead they submit the form before they...
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...
4
by: sowencheung | last post by:
Hi, all The scenario is like this: I have a master page, contains two user controls, one is a search control, another is a login control. The server-side <form> is in the master page,...
4
by: portCo | last post by:
Hello there, I am using Visual Basic 2005. I want to store a value when I press enter key on the keyboard. Could anyone help me out? Thanks alot.
3
by: Jake Barnes | last post by:
I'm researching the Enter key. This is for an Ajax chat application. The designer tells me that she wants people to be able to submit text simply by hitting the Enter key. She wants this to happen...
3
by: Simon Verona | last post by:
Sorry for the repost, but this group seems to be more "active" than the group that I posted my question, and it's probably as valid here as there! I have a usercontrol, which contains a textbox...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.