I love my day job
SharePoint Designer Gotcha: Where's the "action" in my Form Action button? - SharePoint Skater

SharePoint Skater

Custom control and client script aficionado, neck-deep in a simmering SharePoint stew.

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.

Comments

Links (5/17/2009) « Steve Pietrek – Everything SharePoint and Office said:

Pingback from  Links (5/17/2009) « Steve Pietrek – Everything SharePoint and Office

# May 17, 2009 8:19 PM

Kyle Bakker said:

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

# November 17, 2009 3:48 PM

PeterBrunone said:

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

# November 17, 2009 4:08 PM

Geetha said:

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?

# April 28, 2010 1:17 AM

PeterBrunone said:

Hi Geetha,

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

# May 20, 2010 1:43 PM

SharePoint Designer - Pearltrees said:

Pingback from  SharePoint Designer - Pearltrees

# January 9, 2012 6:25 PM

Terry said:

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!

# January 17, 2012 10:36 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)