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

I have the following javascript:


And I'm wondering if there is a Server Side Object Model equivalent to this that I could use in Page Load?

The javascript is on an ascx that is being displayed when users click on an custom button that has been added to the ribbon.

share|improve this question
up vote 1 down vote accepted

Umm, they are only selecting things on the client side so no, there isn't anything on the server side.

They way i've handled what I think you are trying to accomplish is to pass the values through a querystring. See code below:

function myAction(){
    var items = SP.ListOperation.Selection.getSelectedItems();
    var listId = SP.ListOperation.Selection.getSelectedList();
    var itemCount = CountDictionary(items);

    if (itemCount == 0)

    var ids = "";
    for (var i = 0; i < itemCount; i++) {
        ids += items[i].id + ";";

    var uri = "_layouts/CustomApp.aspx";
    var queryParams = "?listId=" + listId + "&itemIds=" + ids;
    var relativeUrl = L_Menu_BaseUrl;

    var options = {};
    options.url = appendTrailingSlash(relativeUrl) + uri + queryParams;
    options.title = 'Custom App';
    options.autoSize = true;
    options.showClose = true;
    options.allowMaximize = true;
    options.dialogReturnValueCallback = onFinish;


function appendTrailingSlash(url) {
    if (url.length > 0 && url.charAt(url.length - 1) == '/')
        return url;
        return url + '/';
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.