View Full Version : Connect a textbox to the Enter key
pongourcom1
06-01-2005, 07:26 AM
One of my web application has a Textbox. I wantit to receive mouse cursor by default and to respond to the the user pressing the Enter key on the keyboard instead of clicking on a button. It's possible with a Window appliction but how canwe do that in a web application?
Thanks.
Scott
06-01-2005, 09:44 AM
The following function will permit you to set the focus to your textbox or any other control by calling SetFocus(ControlNameHere)
[quote]'------------------------------------------------
subSetFocus(byvalctrlassystem.web.ui.control)
dimsasstring='<scriptlanguage='javascript'>document.getElementById(''&ctrl.ID&'').focus()'&'<'&'/script>'
RegisterStartupScript('focus',s)
endsub
</CODE>
Set the AutoPostBack property of the text box to true to cause a postback when the user enters data in the textbox and handle it using the TextChanged event.
pongourcom1
06-01-2005, 10:32 AM
Yes you have addressed the first part of my question. What about having the textbox catch the Enter key?
Thanks.
Scott
06-01-2005, 10:45 AM
The last line of my previous post addressed the second part.
vBulletin® ©Jelsoft Enterprises Ltd.