SharePoint Designer Gotcha: Where's the "action" in my Form Action button?

It seemed simple enough.

I built a custom New Item form.  Naturally, it needed to redirect to another page after completion.  Normally for a "return page" function, a "Source" parameter in the querystring will suffice, but that didn't seem to work here.  I found the Form Action Button (under Insert->SharePoint Controls->More SharePoint Controls), added Commit and Redirect actions, told it what page to use, and presto!

Nothing happened.

In fact, it didn't even try to submit the form.

A look at the markup revealed that the "Form Action Button" was just a regular old input type="button".  SharePoint Designer was supposed to add an event handler with a JavaScript call, but there appears to be a bug in Designer.  Apparently if there is another HTML button nearby, the event handler can end up there instead!  I've included the code so you know what to look for if this ever happens to you:

  onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={Thanks.aspx}')}"

Your actions may be slightly different, but that's the basic idea.  All you need to do is to cut/paste this bit into your *actual* button -- or any other control, really -- and you'll have the behavior you expected in the first place.

Whew.

5 Comments

  • You are my hero. So simple. So many complicated solutions out there that dont work. Then here you are. One line of code.

  • Thanks, Kyle! It's good to know that my simple-minded approach to development is still popular with regular people :)

  • Have worked with form action buttons. its a gr8 deal of help much simplifying the code. but problem with them is that, validations are not getting fired. it wont ask for the required fields but rather submit the blank data in newform.aspx. that is the main draw back i found out.

    is there any possibility or attribute to set the causes validations property for form action button?

  • Hi Geetha,

    Not likely, but you could include a call to the validation function in your button's onclick event handler.

  • Wow, you are great - this code snippet really helped.  I was seching for a way to do this. your basic idea was easy to follow and it worked right away.

    Thanks!

Comments have been disabled for this content.