CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: HTML

Client Side AJAX Applications in Sharepoint 2010 - Part 2

569 Views
Copy Code Show/Hide Line Numbers
<asp:Content ID="PageHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <style type="text/css">
          .sys-template
          {
            display: none;
          }
    </style>
    
<script src="../Scripts/MicrosoftAjax/MicrosoftAjax.js" type="text/javascript"></script> 
<script src="../Scripts/MicrosoftAjax/MicrosoftAjaxDataContext.js" type="text/javascript"></script>
<script src="../Scripts/MicrosoftAjax/MicrosoftAjaxTemplates.js" type="text/javascript"></script>
<script src="../Scripts/MicrosoftAjax/MicrosoftAjaxOpenData.js" type="text/javascript"></script>
 
   <script type="text/javascript">
        function pageInit() {
 
            var dataContext = $create(Sys.Data.DataContext, {
                serviceUri: "/_vti_bin/listdata.svc"
            });
 
            
            //if we use OpendataServiceProxy instead of DataContext, everything works
            //var dataContext = new Sys.Data.OpenDataServiceProxy("/_vti_bin/listdata.svc");
 
            $create(Sys.UI.DataView,
                    {
                        autoFetch: true,
                        dataProvider: dataContext,
                        fetchOperation: "Announcements"
                    },
                     {},
                     {},
                     $get("AnnouncementsList")
                 );
         }
         Sys.Application.add_init(pageInit);
 
 
    </script>
</asp:Content>
 
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
    <ul id="AnnouncementsList" class="sys-template">
        <li>{{ Title }}</li>
    </ul>
</asp:Content>
by Ross
  August 11, 2010 @ 7:41am
Tags:

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate