Solved

SharePoint 2010 WebPart Enter Key Behaviour

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

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

I have just recently built a new SharePoint 2007 farm on a complete Windows 2008 R2 server platform and part of my standard build procedure is to implement a warm up routine, usually in the form of a script that is scheduled every morning to launch …
I recently came across an issue with a MOSS 2007 deployment where access into some sub-sites were denied, even for the MOSS farm administrators. A bit of background to the setup of this MOSS farm; this was a three server setup, consisting of a fr…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

21 Experts available now in Live!

Get 1:1 Help Now