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

2 Answers 2


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;


I have written a series of blog posts about using SharePoint ribbon customizations here: http://sharepointnadeem.blogspot.in/search/label/Ribbon

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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