Silverlight Image view control web part for MOSS 2007 page


SharePoint 2007 doesn't support multimedia rich media webpart so far as the out of box feature is concerned. hence we need to do some workaround to achieve this using silver light.

A web part to show Image viewer that takes inputs from SharePoint 2007 Picture Library. The image viewer control is developed with Silverlight.

The purpose of this web part is to show the pictures exist within a picture library of a SharePoint 2007 site. It was not possible to show the pictures with a better presentable way by using normal web part. For this reason Silverlight is incorporated within the SharePoint web part to present the pictures within a rich user interface.

As per the detail functionality of this web part, it will pick up all the pictures from the Picture library and show all as a numb nail view. And on the click of a individual picture the large frame will show that particular picture in a larger view.

Features/Approach:


Sr. No
Configurable Feature
Approach
1
Ability to configure the picture library from which the pictures are to be shown
Create a custom property – Library Name
2
Ability to configure the media type
Create a custom property- Media Type
3
Runs without much configuration except the configuration for Silverlight.
It’s a one time job for all the Silverlight applications to be run within SharePoint environment.

Technical Implementation:

There are 3 main steps for integrating Silverlight controls within the SharePoint environment:
·         Create the Silverlight application.
·         put the Silverlight application somewhere on the server so that it is accessible from SharePoint.
·         Create a web part to host the Silverlight application (this is in 2 sub-steps).
o   Use one of the standard SharePoint content editor web parts, and customize it.
o   Create a completely new custom web part, using Visual Studio.
  1. Using SharePoint Content Editor Web part.
This scenario is not applicable for current scope of work. It will work for any other Silverlight control which can play independently.
Before this will work, you need to install the System.Web.Silverlight.dll from the Silverlight SDK\Libraries\Server folder to the GAC, so that SharePoint can find it.
Add a content editor web part on the home page. Then you’ll see a link to open the tool pane. Click this link, and then in the tool pane, click the Source Editor Button.
for the Silverlight host control from the TestPage.html that VS generates for you for the Silverlight application project (you’ll find this in the bin\debug folder). Paste this into the Source Editor window. You need to make 3 changes to this HTML: specify explicit pixel values for the width and height of the Silverlight control; specify the same width and height for the Silverlight application within the control; and specify the full path to the XAP:
<div id="silverlightControlHost">
  <object data="data:application/x-silverlight,"
  type="application/x-silverlight-2" width="400px" height="120px">
    <param name="source
    value="http://consults42s1002:8880/XAPS1/Filmstrip.xap"
    <param name="onerror" value="onSilverlightError" />
    <param name="background" value="white" />
    <param name="minRuntimeVersion" value="2.0.31005.0" />
    <param name="autoUpgrade" value="true" />
    <a href="http://go.microsoft.com/fwlink/?LinkID=124807"
   
style="text-decoration: none;">
      <img src="http://go.microsoft.com/fwlink/?LinkId=108181"
      alt="Get Microsoft Silverlight" style="border-style: none"/>
    a>
  object>
  <iframe style='visibility:hidden;height:0;width:0;border:0px'>
  iframe>
div>



  1. Create a completely new custom web part, using Visual Studio.
In this process the CreateChildControls overrides to instantiate a Silverlight control, and set its Source property to the Silverlight XAP.

silverlightControl.Source = SPContext.Current.Site.Url + "/XAPS1/SL.XAML.MediaViewer.xap";

4.1    Web.config setting for silverlight webpart:


  1. Find the group under and add the following before the closing tag

<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere" />

<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication" />

sectionGroup>
sectionGroup>
sectionGroup>


  1. Next, find the section under and add the following safe control entry.

<SafeControl Assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" Namespace="System.Web.UI.SilverlightControls" TypeName="*" Safe="True" />

  1. Then, add the following section to the section immediately before the closing tag.

<remove verb="*" path="*.asmx" />

<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false" />


  1. Add this next entry to the section under .

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />


  1. In the section, add these entries.
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />

<add assembly="System.Web.Silverlight, Version=2.0.5.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />


  1. Now, add these entries to the group.
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />


  1. Finally, to the section, add the following to the group before any other entries.
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0" />
dependentAssembly>



  1. There are some additional configuration changes that will need to be made if you are using Windows Server 2008 or IIS 7. My test environment is running Windows Server 2003 with IIS 6 and therefore does not require them. Creating a new Silverlight web project in Visual Studio will create a web.config file with the required entries for IIS 6 and IIS 7.

  1. Please pay special attention to step 7 in the referenced blog post above. This step is critical and your Silverlight apps will not work unless you register this MIME type correctly

  1. Add a .XAP MIME type into IIS

1.    Go to StartàRun
2.    Write “inetmgr” within the run text box and press enter. IIS manager window will be opened.


3.    Now right click on the server name and go to “Properties” and click on it.
4.    In the Properties Dialog, click on the "MIME Types" button, see figure below.

5.    In the "MIME Types" Dialog, click the "New" button, see figure below

6.    In the "MIME Type" Dialog enter one MIME Type at the time:
.xap     application/x-silverlight-app
.xaml    application/xaml+xml
.xbap    application/x-ms-xbap