0

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">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition Location="Ribbon.ListItem.Share.Controls._children">
          <Button
            Id="Ribbon.Documents.Share.Controls.NewButton"
            Sequence="5"
            Command="ShowAlert"
            Image16by16="/_layouts/$Resources:core,Language;/images/formatmap16x16.png" Image16by16Top="-16" Image16by16Left="-88"
            Image32by32="/_layouts/$Resources:core,Language;/images/formatmap32x32.png" Image32by32Top="-128" Image32by32Left="-448"
            LabelText="$Resources:core,cui_ButEmailLink;"
            ToolTipTitle="$Resources:core,cui_ButEmailLink;"
            ToolTipDescription="$Resources:core,cui_STT_ButEmailLinkDocument;"
            TemplateAlias="o1" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler Command="ShowAlert" CommandAction="javascript:alert('Hello world!');" />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>

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

1

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;

1

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, privacy policy and cookie policy

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