I have 2 web parts on the page, a DataFormWebPart and a XsltListViewWebPart. I'm trying to do some custom validation for the XsltListViewWebPart and would like to do it on the presave event.

Currently I am using PreSaveAction() to do some validation on the DataFormWebPart and this works fine. I have tried the PreSaveAction() and PreSaveItem() events for the XsltListViewWebPart however neither one gets fired. Does anyone know if there is a presave event on a XsltListViewWebPart?

I've looked at the XML for the XsltListViewWebPart and there doesn't seem to a straight forward way to edit the save button JavaScript either. Any help or suggestions would be greatly appreciated.

  • What are you actually saving? In a Data form web part you can edit and save an individual item. An XLV shows a list of items. Where does saving come in? – teylyn Dec 18 '14 at 7:25
  • I'm saving per item in the XLV web part where a user can edit one item at a time. – Steve Dec 18 '14 at 21:52

Are you using a custom form action button or the default save button?

If you are using a custom form action button then you need to add the PreSaveAction manually.

<a id="savebutton" href="javascript: if (PreSaveAction()) {ddwrt:GenFireServerEvent('__commit;dvt_1_form_insertmode={1}')}"  style="">Save and View</a>
| improve this answer | |
  • It's the default save button on the XsltListViewWebPart which saves per item. I've looked at the XML for the web part and can't see where the save/delete buttons are created. – Steve Dec 18 '14 at 21:52
  • Can you post your PreSaveAction() code? – Bryan Mathews Dec 19 '14 at 14:16
  • function PreSaveAction() { var isAllValid = false; isAllValid = ValidateMandatoryfields(); return isAllValid; } This works however isn't fired on the save event of the XSLTListViewWebPart save button. – Steve Dec 22 '14 at 1:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.