Solved

C# DetailsView set focus

Posted on 2012-04-13
1
498 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

12 Experts available now in Live!

Get 1:1 Help Now