?
Solved

SharePoint 2010 WebPart Enter Key Behaviour

Posted on 2012-03-20
3
Medium Priority
?
964 Views
Last Modified: 2012-06-21
Hi,

I've created a Multiple Item Form Webpart in SharePoint Designer (aka a DataFormWebPart), for SharePoint 2010. It has multiple rows and each row has multiple fields in text boxes. There is a Save and Cancel button at the bottom.

Note that this is created in Designer, not in code.

The problem I have is that if the user hits the enter key after typing a value anywhere in the form, the page refreshes and all the entries they have made vanish.

I would like it if either nothing happend if the user pressed Enter, or if at the form would save all the data.

The page this is has three web parts, and this problem occurs in second and third webparts. I think what is happening is that the first button in the first web part (and so the first button on the page) is responding to the Enter key. I can see it has focus in the browser.

I thought I could fix this by changing the DefaultButton property for the webpart to "DefaultButton='btnSave'", but that doesn't work.

I do notice that the btnSave doesn't actually post the form, but rather runs JavaScript in its onClick() event. Maybe that has something to do with it. I don't know.

Any ideas how I fix can fix this.
0
Comment
Question by:LTIADMIN
[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
  • 2
3 Comments
 
LVL 15

Expert Comment

by:dp_expert
ID: 37746689
Can you open the development toolbar in IE and switch to the "Script" tab and start debugging and next press "Enter" to pinpoint where in code this key press is being intercepted?
0
 

Accepted Solution

by:
LTIADMIN earned 0 total points
ID: 37808146
I figured out a way arund this in JavaScript. With the onkeypress event that SharePoint provides for the fields I added a call to a JS function that just tells it to ignore the enter key press. Works well.
0
 

Author Closing Comment

by:LTIADMIN
ID: 37822761
Ansered it myself
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

I used to be SharePoint evangelist in our company, so my Outlook always full of questions about how to do this, or where I can find that. One day I found such an email with the following question: "how to attach 3-State workflow (one of the workflow…
Microsoft SharePoint Foundation 2010 and Microsoft SharePoint Server 2010 do not offer the option to configure the location of the SharePoint diagnostic trace log files during installation.  This can, however, be configured through Central Administr…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

764 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