Ask a Question related to ASP.NET General, Design and Development.
-
DDK #1
Textbox, button and Enter on keyboard
Question (using C# and ASP.NET),
I have a textbox and a buttonClick on my asp.net page. I would
like be able to hit the Enter button on the keyboard and have it do the
same thing as the buttonClick. In other words how do you get Enter button
on the key board to perform the same operation as a button click event.
Any help would be great,
Thanks
D.
DDK Guest
-
How to control enter button on the client PC in ASP.Net
Does anybody know how to control enter button on the web form? It seems to if the user hits enter button at run time then it fires submit button... -
Textbox and button -- enter key/submit - REFERENCE
Hi, as you can see from my many posts the past few days, I have certainly been confused about the firing/non-firing of my textboxes and buttons. In... -
Q: Textbox press Enter submit form (ASCX version)
Hello all, It's known to how to make user press enter in an asp:textbox and the form is submited by adding an attribute to the textbox with an... -
Get text in TextBox without pressing Enter key
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... -
why datagrid's itemcommand event fired when I press ENTER key in a TextBox
Hi, When you press the ENTER key the default button pressed and since the only button is the column template one a post back to the server... -
Steve C. Orr, MCSD #2
Re: Textbox, button and Enter on keyboard
You can intercept the client side enter keypress event of the text box and
then click
the correct button using javascript code.
Here's a good example:
[url]http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18[/url]
You could also try using this free control.
[url]http://www.metabuilders.com/tools/DefaultButtons.aspx[/url]
--
I hope this helps,
Steve C. Orr, MCSD
[url]http://Steve.Orr.net[/url]
"DDK" <ddkennard@hotmail.com> wrote in message
news:OFDJbyzSDHA.1684@TK2MSFTNGP11.phx.gbl...> Question (using C# and ASP.NET),
>
> I have a textbox and a buttonClick on my asp.net page. I would
> like be able to hit the Enter button on the keyboard and have it do the
> same thing as the buttonClick. In other words how do you get Enter button
> on the key board to perform the same operation as a button click event.
>
> Any help would be great,
> Thanks
>
> D.
>
>
Steve C. Orr, MCSD Guest
-
Vidar Petursson #3
Re: Textbox, button and Enter on keyboard
Hi
Basic example... simply say what submitbutton should be clicked onkeydown
event
I think this will work in netscape also but havent tested it....
<html>
<head>
<SCRIPT>
function submitOnEnter(submitBtn) {
var keyCode = document.all ? event.keyCode :evt.which ? evt.which :
evt.keyCode ? evt.keyCode : evt.charcode;
if (keyCode == 13) submitBnt.click();
}
</script>
</head>
<body>
<form >
<input type="text" name="myField"
onkeydown="submitOnEnter(this.form.submitBtn1)">
<input type="submit" name="submitBtn1" value="submit1">
<input type="text" name="myField"
onkeydown="submitOnEnter(this.form.submitBtn2)">
<input type="submit" name="submitBtn2" value="submit2">
</form>
</body>
</html>
So if sumbitOnEnter-script is registered and you want to set some field to
use it
myInput.Attributes.Add("onkeydown","submitOnEnter( this.form." + BUTTONNAME +
")");
Where BUTTONNAME is the button (surprise ;) ) to click
--
Best Regards
Vidar Petursson
==============================
Microsoft Internet Client & Controls MVP
==============================
"DDK" <ddkennard@hotmail.com> wrote in message
news:OFDJbyzSDHA.1684@TK2MSFTNGP11.phx.gbl...> Question (using C# and ASP.NET),
>
> I have a textbox and a buttonClick on my asp.net page. I would
> like be able to hit the Enter button on the keyboard and have it do the
> same thing as the buttonClick. In other words how do you get Enter button
> on the key board to perform the same operation as a button click event.
>
> Any help would be great,
> Thanks
>
> D.
>
>
Vidar Petursson Guest



Reply With Quote

