Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to create a custom action that does a postback when clicked.

I've followed the following articles with no luck whatsoever:

  1. http://makarandrkulkarni.blogspot.com/2010/01/sharepoint-2010-ribbon-customization_09.html

  2. http://blog.dennus.net/2010/07/20/ribbon-buttons-with-postback-in-sp2010/

  3. http://blogs.msdn.com/b/sridhara/archive/2010/12/30/implementing-a-post-back-button-in-a-sharepoint-2010-web-part-with-contextual-ribbon.aspx

Frankly, artcle 3 is a ridiculous amount of work just to do a postback so I didn't even attempt it.

I've managed to get the button on the ribbon but without the CommandUIHandler element in the elements.xml the button is forever disabled.

Anyway, this is what I'm trying to achieve:

I have an external list. I want a custom action on the list that updates a field in another database when it is clicked. Now, this doesn't have to be via a postback, I am open to any suggestions anyone has - I just thought doing a postback would be simple, obvisouly I was wrong. This, so I've heard was stupidly easy in SP 2007.

Thanks in advance for any help/suggestions.

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

If it is a single administrative action, you can simply use SharePoint Designer for creating a ribbon button: http://msdn.microsoft.com/en-us/library/ee558387.aspx

For performing your field update, you can then use workflow or Application Page with query string parameters.

If you need reusable solution (for wsp), I recommend you to use SharePoint 2010 Fluent Ribbon API. It is a codeplex project, which simplifies operations with ribbon.

You can run any JS on ribbon button click.

For further details, please, visit the project's documentation site.

About the postback solution:

Most likely, postback is not a good way here, because AllItems form of an External list is not a page with your code behind. And to get this postback to work, you will need some extra magic, for example, you can deploy your own webpart on the same page and when you can use __doPostBack from javascript, and this.Page.Request["__EVENTTARGET"] from your code. I don't recommend you to use this solution, even if it is possible.

share|improve this answer
    
The SharePoint 2010 Fluent Ribbon API is amazing. Thank you for sharing this! –  Jamie Apr 27 '11 at 8:18
add comment

It can still be easy depending on what you want to do. SharePoint Designer supports the ability to add custom actions to the Ribbon menu without having to write any code that can navigate to a form (with query parameter tokens), start a workflow, or open any url and it provides a simple dialog UI for customizing the button.

  1. Open SharePoint Designer
  2. Open any List or Library
  3. Find the Custom Actions area on the designer page
  4. Add new Custom Action...

You can also initiate adding a new Ribbon button directly from the SharePoint UI. Navigate to a list or library (with designer permissions), and click "New Quick Step" from the Ribbon menu. This will open SharePoint Designer.

I hope this helps. If you want to see how they are doing it, you can save the site as a template and import it into Visual Studio. This of course assumes that you do not need to combine client-side processing and then invoke a post-back from client-side.

If you need to force a post-back from a JavaScript stub, the easiest way is to just find the ASPNET form node (SharePoint pages only have a single form instance) and do a submit. Let me know and I can probably find a quick sample.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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