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 have the following javascript:

SP.ListOperation.Selection.getSelectedItems();

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
add comment

1 Answer

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)
        return;

    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;

    SP.UI.ModalDialog.showModalDialog(options);
}


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