SharePoint 2010 WebPart Enter Key Behaviour
Posted on 2012-03-20
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.
Any ideas how I fix can fix this.