Solved

SharePoint 2010 WebPart Enter Key Behaviour

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

There is one common problem that all we SharePoint developers share: custom solution deployment. This topic can't be covered fully in this short article, so all I want to do in this one is to review it from a development-to-operations perspectiv…
We had a requirement to extract data from a SharePoint 2010 Customer List into a CSV file and then place the CSV file into a directory on the network so that the file could be consumed by an AS400 system. I will share in Part 1 how to Extract the Da…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

19 Experts available now in Live!

Get 1:1 Help Now