Solved

C# DetailsView set focus

Posted on 2012-04-13
1
500 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
1 Comment
 
LVL 22

Accepted Solution

by:
Mrunal earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Need help parsing JSON in my VB.Net application 4 43
About delegates in c sharp 3 33
C# Json POSt to Rest API 4 36
Vb. Net application freezes 9 30
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now