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 | 1 Comment

Post navigation

One thought on “Capture Enter Key in ASP.NET’s Textbox

  1. Wow, I’ve definitely learned the techniques in this comprehensive tutorial.
    Thank you for sharing this information.

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 )

Google+ photo

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

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: