SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My question is regarding the button on the ribbon and client object model code. I'm not sure how to do it: So i have a button here:

<CustomAction Id="NewButton" Location="CommandUI.Ribbon" RegistrationId="103" RegistrationType="List">
        <CommandUIDefinition Location="Ribbon.ListItem.Share.Controls._children">
            Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-16" Image16by16Left="-88"
            Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-448"
            TemplateAlias="o1" />
        <CommandUIHandler Command="ShowAlert" CommandAction="javascript:alert('Hello world!');" />

In this case it is just some simple java script: but i want to use more complex code, client side object model. How to arrange that?

And directly another question in the code how can i check what kind of element is selected? like is it just an item or a document or a folder?

Thanks in advance

share|improve this question
up vote 1 down vote accepted

If you want to do more complex things with the ribbon I think its best to use a page component.

Waldek Mastykarz has written a nice article with many links about using a page component.

But also Chris O'Brien has written fine articles about complex code when using the ribbon.

Regarding your second question you can use get_fileSystemObjectType() method on a selected item;

share|improve this answer

I have written a series of blog posts about using SharePoint ribbon customizations here:

share|improve this answer

Your Answer


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.