Solved

SharePoint 2010 WebPart Enter Key Behaviour

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

786 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