Tuesday, November 23, 2010

Silverlight Webpart to show List Item Count

First of all Thanks to vistit this blog this is my very first blog  :)        
My last project on Silverlight 4(MVVM,Entity framework,WCF) ,I will  expalin what i did in that but this post very much related to Silverlight + MOSS 2010.

few importan tips than need to keep in mind before start coding

Silverlight client object model can handle both scenarios. If your code does not modify the UI directly, you can use the synchronous method(ExecuteQuery). If your application directly updates the interface, you need to use ExecuteQueryAsync. In my application the snippet above is running in a background thread that does not update the UI, so both methods work. There was no real need to use the asynchronous method.

Requirment :  Create a Silverlight webpart to show List ItemCount dyanmically with passing parameter.
SivlerLight webpart use ClientObject Model that comes with Sharepoint 2010 it is very easy to create but need to keep some points in mind.
1.Whenever we create clientcontext always call  Execute Query Asynchronously(ExecuteQueryAsync)
2.Wirite logic in ClientRequestSucceededEventHandler for successfully run the query
3.Dont forget to Dispatcher BeginInvoke ()

4.Location of DLL

A.Managed Code "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI".
a.Microsoft.SharePoint.Client.dll
b.Microsoft.SharePoint.Client.Runtime.dll.

B.Silverlight:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin
filename
a.Microsoft.SharePoint.Client.Silverlight.dll
b.Microsoft.SharePoint.Client.Silverlight.Runtime.dll

C.EcMAScript:C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS".
a.SP.js file