Capture Enter Key in ASP.NET’s Textbox

Here is some sample code on how to capture the enter key on a textbox in ASP.NET. I am posting this because I use it a lot.

function KeyDownHandler() {
if (event.keyCode == 13) {
event.returnValue = false;
event.cancel = true;
document.getElementById(‘cphmainContent_C008_LoginButton’).click();
}
}

Then add this to your textobox:
onkeydown=”KeyDownHandler();”

Categories: SharePoint or Custom Development | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Blog at WordPress.com. Theme: Adventure Journal by Contexture International. Fonts on this blog.

Follow

Get every new post delivered to your Inbox.