Solved

SharePoint 2010 WebPart Enter Key Behaviour

Posted on 2012-03-20
3
925 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Note:  There are two main ways to deploy InfoPath forms:  Server-side and directly through the SharePoint site.  Deploying a server-side InfoPath form means the form is approved by the Administrator, thus allowing greater functionality in the form. …
The Scenario: Let’s say you have a quote worksheet in Excel that you use to work up sales figures and such for your clients. You utilize SharePoint to manage and keep track of these documents. You would like values from your worksheet to populate Sh…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

736 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