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 am having trouble getting the selected items from a ListViewByQuery webpart, using the Client Object Model (JavaScript).

Code (server-side)

<SharePoint:ListViewByQuery runat="server" ID="lvbqMyNews" Enabled="True" DisableSort="False" DisableFilter="False" />

Code (client-side)

var context = SP.ClientContext.get_current();

//returns: [] when anything is selected.

I've tested the same code when going to a normal List in SharePoint, where it gets the selected items perfectly.


I am not able to get the selected items from the Embedded ListViewByQuery webpart (User control), when I have selected from a ListViewByQuery in a Webpart where I have added the control myself.

If I attempt the same operation on a normal list, then there is no problem getting the list of items. It seems like the Client Object Model is not aware of the ListViewByQuery webpart..

share|improve this question
up vote 1 down vote accepted

I think your syntax for the Client Object Model might not be correct. It should be:

var context = SP.ClientContext.get_current();

It's SP.ClientContext and not SP.Context.

Also, you could try using the XSLTListViewWebPart instead of ListViewByQuery webpart. I have used it successfully before, with the SP.ListOperation namespace.

See the following links:

share|improve this answer
May I ask if why is it possible to do this only on client side why not on the server side with c# code ??? – Glolita Apr 15 '13 at 15:47

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.