Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

C# DetailsView set focus

Posted on 2012-04-13
1
Medium Priority
?
528 Views
Last Modified: 2012-05-08
I have a DetailsView that on its PreRender method, I set the Focus of the page to one of the textboxes inside the Details View.  It appears to work as a blinking cursor appears in the textbox I set the focus to.  However if I just press the enter key, the first Button on the page acts as if it has been clicked and executes its code.  I was just wondering how to stop the button from acting as if it was clicked and have the enter key do nothing when it is pressed
0
Comment
Question by:zintech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
Mrunal earned 2000 total points
ID: 37858928
With the help of jQuery:

$("#TextBoxID").keypress(function() {
    var code = (e.keyCode ? e.keyCode : e.which);
    if(code == 13) { //Enter keycode
        return false;
    }
});


With javaScript:

http://www.rgagnon.com/jsdetails/js-0118.html

http://www.arraystudio.com/as-workshop/disable-form-submit-on-enter-keypress.html
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question