Enter event on control

C

csgraham74

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
 
X

xamman

if i understood correctly what you are doing, i think you need to
override createchildcontrols and use the addhandler method
 
T

TiSch

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
 

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,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top