Documente Academic
Documente Profesional
Documente Cultură
Objectives:
Operating Notes:
Deliverables:
• None
Overview: In this activity, we will make a web part that uses SilverLight!
Purpose: Install SilverLight binaries on your client so you can create and use
SilverLight applications.
2. Click “Next”
SilverLight
Module #xx Lab #02 Page 2 of 22
www.architectingconnectedsystems.com
SilverLight
3. Click “Next”
4. Click “Next”
SilverLight
Module #xx Lab #02 Page 3 of 22
www.architectingconnectedsystems.com
SilverLight
5. Click “Install”
6. Click “Next”
7. For “Alias”, type “ClientBin”
SilverLight
Module #xx Lab #02 Page 5 of 22
www.architectingconnectedsystems.com
SilverLight
8. Click “Next”
9. For path, type “C:\Inetpub\wwwroot\wss\VirtualDirectories\100\ClientBin”
10. Click “Next”
11. Click “Run scripts (such as ASP)” checkbox
SilverLight
Module #xx Lab #02 Page 6 of 22
www.architectingconnectedsystems.com
SilverLight
SilverLight
Module #xx Lab #02 Page 7 of 22
www.architectingconnectedsystems.com
SilverLight
<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>
SilverLight
Module #xx Lab #02 Page 8 of 22
www.architectingconnectedsystems.com
SilverLight
<controls>
<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" />
</controls>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<remove name="ScriptModule" />
<add name="ScriptModule" preCondition="managedHandler"
type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0,
Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated" />
<remove name="ScriptHandlerFactory" />
<remove name="ScriptHandlerFactoryAppServices" />
<remove name="ScriptResource" />
<add name="ScriptHandlerFactory" verb="*" path="*.asmx"
preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd"
preCondition="integratedMode"
type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions,
Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD"
path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler,
System.Web.Extensions, Version=3.5.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
</handlers>
<security>
<authorization>
<add accessType="Allow" users="" />
<add accessType="Allow" users="?" />
SilverLight
Module #xx Lab #02 Page 9 of 22
www.architectingconnectedsystems.com
SilverLight
</authorization>
</security>
</system.webServer>
iisreset
Purpose: Create a SilverLight Control for your SharePoint site. This is done via
JavaScript rather than compiling managed assemblies into XAP files.
<Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="calc"
Width="166"
Height="166"
RenderTransformOrigin="0,0"
>
<Canvas.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FF111479" Offset="0"/>
<GradientStop Color="#FFA9AACE" Offset="1"/>
</LinearGradientBrush>
</Canvas.Background>
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="2" ScaleY="2"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Canvas.RenderTransform>
<Canvas x:Name="n7" Canvas.Top="39.75" Canvas.Left="12" >
<Canvas.RenderTransform>
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
</Canvas.RenderTransform>
<Rectangle Fill="#FFFFFFFF" RadiusX="4" RadiusY="4" Width="26.875" Height="23"
/>
<Rectangle x:Name="buttonBG" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock Canvas.Top="2.1" Canvas.Left="8.833" FontFamily="Arial"
FontSize="14" FontWeight="bold" Text="7" RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
SilverLight
Module #xx Lab #02 Page 10 of 22
www.architectingconnectedsystems.com
SilverLight
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-1.989">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.392"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46" EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
<Canvas x:Name="n8" Canvas.Top="40" Canvas.Left="48.75" >
<Canvas.RenderTransform>
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
</Canvas.RenderTransform>
<Rectangle Fill="#FFFFFFFF" RadiusX="4" RadiusY="4" Width="26.875"
Height="23" />
<Rectangle x:Name="buttonBG1" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock Canvas.Top="2.1" Canvas.Left="8.833" FontFamily="Arial"
FontSize="14" FontWeight="bold" Text="8" RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-
1.989">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.392"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46"
EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
<Canvas x:Name="fequals" Canvas.Top="131" Canvas.Left="84" >
<Canvas.RenderTransform>
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
</Canvas.RenderTransform>
<Rectangle Fill="#FFFFFFFF" RadiusX="4" RadiusY="4" Width="26.875" Height="23"
/>
<Rectangle x:Name="buttonBG2" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock Canvas.Top="2.1" Canvas.Left="8.833" FontFamily="Arial"
FontSize="14" FontWeight="bold" Text="=" RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-1.989">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.392"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46" EndPoint="0.516,3.018">
SilverLight
Module #xx Lab #02 Page 11 of 22
www.architectingconnectedsystems.com
SilverLight
Height="23" />
<Rectangle x:Name="buttonBG5" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock Canvas.Top="2.1" Canvas.Left="8.833" FontFamily="Arial"
FontSize="14" FontWeight="bold" Text="3" RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-
1.989">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.392"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46"
EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
<Canvas x:Name="n2" Canvas.Top="100.75" Canvas.Left="48.25" >
<Canvas.RenderTransform>
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
</Canvas.RenderTransform>
<Rectangle Fill="#FFFFFFFF" RadiusX="4" RadiusY="4" Width="26.875" Height="23"
/>
<Rectangle x:Name="buttonBG6" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock Canvas.Top="2.1" Canvas.Left="8.833" FontFamily="Arial"
FontSize="14" FontWeight="bold" Text="2" RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-1.989">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.392"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46" EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
<Canvas x:Name="n1" Canvas.Top="100.25" Canvas.Left="11.75" >
<Canvas.RenderTransform>
<ScaleTransform ScaleX="1.2" ScaleY="1.2" />
</Canvas.RenderTransform>
<Rectangle Fill="#FFFFFFFF" RadiusX="4" RadiusY="4" Width="26.875"
Height="23" />
<Rectangle x:Name="buttonBG7" Canvas.Top="1.5" Canvas.Left="1.5"
Fill="#FF808080" RadiusX="4" RadiusY="4" Width="23.25" Height="20"/>
<TextBlock x:Name="tB1" Canvas.Top="2.1" Canvas.Left="8.833"
FontFamily="Arial" FontSize="14" FontWeight="bold" Text="1"
RenderTransformOrigin="-0.091,0.499" />
<Rectangle Canvas.Top="4" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.535,2.329" EndPoint="0.535,-
1.989">
SilverLight
Module #xx Lab #02 Page 13 of 22
www.architectingconnectedsystems.com
SilverLight
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle Canvas.Top="1.5" Canvas.Left="1.5" RadiusX="4" RadiusY="4"
Width="23.25" Height="16.7">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46"
EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#00FFFFFF" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
</Canvas>
<Rectangle Stroke="#FF000000" RadiusX="4" RadiusY="4" Width="138.75"
Height="23.75" Canvas.Left="12" Canvas.Top="9">
<Rectangle.Fill>
<LinearGradientBrush StartPoint="0.516,-1.46" EndPoint="0.516,3.018">
<GradientStop Color="#FFFFFFFF" Offset="0"/>
<GradientStop Color="#FF808080" Offset="0.586"/>
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Canvas>
<TextBlock x:Name="result" Width="132.75" Height="18.75" Canvas.Left="18"
Canvas.Top="12.5" FontFamily="Arial" FontSize="16" FontWeight="Bold" Text="11111"
TextWrapping="Wrap"/>
</Canvas>
</Canvas>
designerCalc = function() {
this.host = null;
this.n7 = null;
this.buttonBG = null;
this.n8 = null;
this.buttonBG1 = null;
this.fequals = null;
this.buttonBG2 = null;
this.fplus = null;
this.buttonBG3 = null;
this.n0 = null;
this.buttonBG4 = null;
this.n3 = null;
this.buttonBG5 = null;
this.n2 = null;
this.buttonBG6 = null;
this.n1 = null;
this.buttonBG7 = null;
this.n6 = null;
this.buttonBG8 = null;
this.n5 = null;
this.buttonBG9 = null;
this.n4 = null;
this.buttonBG10 = null;
this.n9 = null;
this.buttonBG11 = null;
SilverLight
Module #xx Lab #02 Page 17 of 22
www.architectingconnectedsystems.com
SilverLight
this.fminus = null;
this.buttonBG12 = null;
this.fdivide = null;
this.buttonBG13 = null;
this.fmultiply = null;
this.buttonBG14 = null;
this.result = null;
this.tb1 = null;
}
designerCalc.prototype = {
initializeComponent: function(slhost) {
var host = slhost.content;
this.host = host;
this.n0 = host.findName("n0");
this.n1 = host.findName("n1");
this.n2 = host.findName("n2");
this.n3 = host.findName("n3");
this.n4 = host.findName("n4");
this.n5 = host.findName("n5");
this.n6 = host.findName("n6");
this.n7 = host.findName("n7");
this.n8 = host.findName("n8");
this.n9 = host.findName("n9");
this.buttonBG = host.findName("buttonBG");
this.buttonBG1 = host.findName("buttonBG1");
this.buttonBG2 = host.findName("buttonBG2");
this.buttonBG3 = host.findName("buttonBG3");
this.buttonBG4 = host.findName("buttonBG4");
this.buttonBG5 = host.findName("buttonBG5");
this.buttonBG6 = host.findName("buttonBG6");
this.buttonBG7 = host.findName("buttonBG7");
this.buttonBG8 = host.findName("buttonBG8");
this.buttonBG9 = host.findName("buttonBG9");
this.buttonBG10 = host.findName("buttonBG10");
this.buttonBG11 = host.findName("buttonBG11");
this.buttonBG12 = host.findName("buttonBG12");
this.buttonBG13 = host.findName("buttonBG13");
this.buttonBG14 = host.findName("buttonBG14");
this.fequals = host.findName("fequals");
this.fplus = host.findName("fplus");
this.fminus = host.findName("fminus");
this.fdivide = host.findName("fdivide");
this.fmultiply = host.findName("fmultiply");
this.result = host.findName("result");
}
}
Type.registerNamespace("Custom");
Custom.Calculator = function(element) {
Custom.Calculator.initializeBase(this, [element]);
Custom.Calculator.prototype = {
_events: null,
onPluginLoaded : function(args) {
Custom.Calculator.callBaseMethod(this, 'onPluginLoaded', new Array(args));
SilverLight
Module #xx Lab #02 Page 18 of 22
www.architectingconnectedsystems.com
SilverLight
this._operator = s;
this._recentOperator = true;
return;
}
if (this._recentOperator) {
this._designer.result.Text = s;
this._recentOperator = false;
}
else {
this._designer.result.Text += s;
}
}
}
Custom.Calculator.registerClass('Custom.Calculator', Sys.UI.Silverlight.Control);
1. Open http://servername:100
2. Using SharePoint Designer, open the default.aspx page,
SilverLight
Module #xx Lab #02 Page 19 of 22
www.architectingconnectedsystems.com
SilverLight
<script>
function errorHandler(sender, args)
{
alert(args._error.errorType);
alert(args._error.errorCode);
alert(args._error.errorMessage);
}
</script>
7. Refresh the page in the browser, you should see your new silverlight application!
SilverLight
Module #xx Lab #02 Page 20 of 22
www.architectingconnectedsystems.com
SilverLight
SilverLight
Module #xx Lab #02 Page 21 of 22
www.architectingconnectedsystems.com
SilverLight
SilverLight
Module #xx Lab #02 Page 22 of 22
www.architectingconnectedsystems.com