Solved

C# DetailsView set focus

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

Increase Agility with Enabled Toolchains

Connect your existing build, deployment, management, monitoring, and collaboration platforms. From Puppet to Chef, HipChat to Slack, ServiceNow to JIRA, Splunk to New Relic and beyond, hand off data between systems to engage the right people.

Connect with xMatters.

Question has a verified solution.

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

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

717 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