0

I need to get the items of my SharePoint list : I used COM to get the items. this is the code:

  <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
<%@ Assembly Name="Microsoft.Web.CommandUI, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Import Namespace="Microsoft.SharePoint" %> 
<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ImgAccueilWebPart.ascx.cs" Inherits="BDTN.DeliceDanone.BDTN.ImageAccueilFeature.ImgAccueilWebPart.ImgAccueilWebPart" %>


<script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jquery-1.9.1.min.js"></script>
    <!-- use jssor.slider.mini.js (40KB) instead for release -->
    <!-- jssor.slider.mini.js = (jssor.js + jssor.slider.js) -->
    <script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jssor.js"></script>
    <script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jssor.slider.js"></script>




  <script type="text/javascript" src="../../_layouts/15/SP.js"></script>

<script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jquery-1.9.1.min.js"></script>
    <!-- use jssor.slider.mini.js (40KB) instead for release -->
    <!-- jssor.slider.mini.js = (jssor.js + jssor.slider.js) -->
    <script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jssor.js"></script>
    <script type="text/javascript" src="../../_layouts/15/BDTN.DeliceDanone/scripts/Img-Animation-js-slider/jssor.slider.js"></script>

<script>

    $(document).ready(function () {

        // Make sure the SharePoint script file 'sp.js' is loaded before your
        // code runs.
        //SP.SOD.executeFunc('sp.js', 'SP.ClientContext', retrieveListItems());

        ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");

        var siteUrl = '/sites/test';


        function retrieveListItems() {

            var clientContext = new SP.ClientContext(siteUrl);
            var oList = clientContext.get_web().get_lists().getByTitle('imageAccueilLD ');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><Where><Geq><FieldRef Name=\'ID\'/>' +
                '<Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>');
            this.collListItem = oList.getItems(camlQuery);
            clientContext.load(collListItem);
            clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));

        }

        function onQuerySucceeded(sender, args) {

            var listItemInfo = '';

            var listItemEnumerator = collListItem.getEnumerator();

            while (listItemEnumerator.moveNext()) {
                var oListItem = listItemEnumerator.get_current();
                listItemInfo += '\nID: ' + oListItem.get_id() +
                    '\nTitle: ' + oListItem.get_item('Title');

                $("#puthere").append("<div style='background-color:steelblue'>" +
                            oListItem.get_item('Title') +
                       "</div>");

            }

            alert(listItemInfo.toString());
        }

        function onQueryFailed(sender, args) {

            alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());
        }
    });


</script>


<script>
    jQuery(document).ready(function ($) {
        //$("#puthere").append("<div style='background-color:steelblue'>" +
        //                   "bbb" +
        //              "</div>");
        //$("#puthere").append("<div style='background-color:red'>" +
        //            "ccc" +
        //       "</div>");

        var _SlideshowTransitions = [
        //Fade
        { $Duration: 1200, $Opacity: 2 }
        ];

        var options = {
            $SlideDuration: 500,                                //[Optional] Specifies default duration (swipe) for slide in milliseconds, default value is 500
            $DragOrientation: 3,                                //[Optional] Orientation to drag slide, 0 no drag, 1 horizental, 2 vertical, 3 either, default value is 1 (Note that the $DragOrientation should be the same as $PlayOrientation when $DisplayPieces is greater than 1, or parking position is not 0)
            $AutoPlay: true,                                    //[Optional] Whether to auto play, to enable slideshow, this option must be set to true, default value is false
            $AutoPlayInterval: 1500,                            //[Optional] Interval (in milliseconds) to go for next slide since the previous stopped if the slider is auto playing, default value is 3000
            $SlideshowOptions: {                                //[Optional] Options to specify and enable slideshow or not
                $Class: $JssorSlideshowRunner$,                 //[Required] Class to create instance of slideshow
                $Transitions: _SlideshowTransitions,            //[Required] An array of slideshow transitions to play slideshow
                $TransitionsOrder: 1,                           //[Optional] The way to choose transition to play slide, 1 Sequence, 0 Random
                $ShowLink: true                                    //[Optional] Whether to bring slide link on top of the slider when slideshow is running, default value is false
            }
        };

        var jssor_slider1 = new $JssorSlider$("slider1_container", options);

    });


    </script>

    <div id="slider1_container" style="position: relative; width: 600px;
        height: 300px;">

        <!-- Loading Screen -->
        <div u="loading" style="position: absolute; top: 0px; left: 0px;">
            <div style="filter: alpha(opacity=70); opacity:0.7; position: absolute; display: block;
                background-color: #000; top: 0px; left: 0px;width: 100%;height:100%;">
            </div>

        </div>

        <!-- Slides Container -->
        <div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 300px; height: 200px;
            overflow: hidden;"  id="puthere">

            <div style="background-color:steelblue">
                     aaa
                </div>

        </div>
        <a style="display: none" href="http://www.jssor.com">image slider</a>
    </div>

the error is :

ScriptResource.axd, Line 786 Character SCRIPT5007 71: Unable to get the property "isNullOrUndefined" a reference null or undefined

SP.js Line 2 Character SCRIPT5022 11484: Sys.InvalidOperationException: The type SP.ULSTraceLevel has already been registered. It is possible that this type has been defined several times or the script file that sets has already been loaded. This may be due to a modification of the parameters during a partial update. ScriptResource.axd, 1647 Line 38 Character

Any ideas . Best regards

  • Not able to understand the error, but can you confirm that list title is correct. There is an extra space at the end of list title here var oList = clientContext.get_web().get_lists().getByTitle('imageAccueilLD '); – Nadeem Yousuf Feb 5 '15 at 10:08
  • i eleminate the : <script type="text/javascript" src="../../_layouts/15/SP.js"></script> and the extra space and it works – Imen Turki Feb 5 '15 at 16:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.