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 requirement which is

  1. Retrieve List Items in a List(list created through OOB)
  2. Display those list items on the sharepoint site by binding to repeator control
  3. Using javascript and client object model.

Steps I have done

  1. Created a new SharePoint Project
  2. Added a new Application Page to the project
  3. Wrote the below code

<script type="text/javascript">
    var ListItem;
    function GetListItems(listname, listItemId)
    {
        var SPContext = new SP.ClientContext.get_current();
        var web=SPContext.get_web();

        var List=web.get_lists().getByTitle("Menu Items");
        ListItem = list.getItemById(listItemId);

        SPContext.load(ListItem,"Menu_Title","Menu_Image","Menu_Description");
        SPContext.executeQueryAsync(GetListItemById);
    }
    function GetListItemById_Successor(sender, args)
    {
        var id = ListItem.get_id();
        var title = ListItem.get_item("Menu_Title");
        var Image = ListItem.get_item("Menu_Image");
        var Description = ListItem.get_item("Menu_Description");
        alert("Updated List Item: \n Id: " + id + " \n Title: " + title+ "\n Image:" +Image+ "\n Description:" +Description );
    }
    function GetListItemById_Fail(sender, args)
    {
        alert("GetListItemById Failed. \n" + args.get_message() + "\n" + args.get_stackTrace());
    }
</script>

My code deploys successfully with no errors but not able to see... Please help me on this,I am not getting an intellisense menu for the client object model classes and objects.

Is there a step by step process tutorial or suggestions are highly appreciated

Retreving items in a SharePoint list using Client Object Model in javascript and bind that to repeator control

share|improve this question
    
executeQueryAsync() should contain success and fail callbacks both. example: executeQueryAsync(GetListItemById_Successor, GetListItemById_Fail); –  Garima Jan 8 at 10:13

1 Answer 1

instead of:

SPContext.executeQueryAsync(GetListItemById);

do:

SPContext.executeQueryAsync(Function.createDelegate(this, this.GetListItemById_Successor), Function.createDelegate(this, this.GetListItemById_Fail));        

http://msdn.microsoft.com/en-us/library/hh185007(v=office.14).aspx

share|improve this answer

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.