http://karinebosch.wordpress.com/2009/07/24/create-a-sharepoint-application-page-hosting-a-silverlight-3-application/
You can download the demo project here. Have fun with it!
The <asp:Silverlight> control but if you want to keep up with the newest technologies, you adapt to the rules.
In that case you can use the <object> tag to create the Silverlight application. The code snippet below contains the entire application page.<%@ Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> <%@ Page Language="C#" MasterPageFile="~/_layouts/application.master" Inherits="Microsoft.SharePoint.WebControls.LayoutsPageBase" %> <%@ Import Namespace="Microsoft.SharePoint" %> <asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server"> <script type="text/javascript"> function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\n"; errMsg += "Code: " + iErrorCode + " \n"; errMsg += "Category: " + errorType + " \n"; errMsg += "Message: " + args.ErrorMessage + " \n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \n"; errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } else if (errorType == "RuntimeError") { if (args.lineNumber != 0) { errMsg += "Line: " + args.lineNumber + " \n"; errMsg += "Position: " + args.charPosition + " \n"; } errMsg += "MethodName: " + args.methodName + " \n"; } throw new Error(errMsg); } </script> <div id="silverlightControlHost" style="width:300;height:100"> <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%"> <param name="source" value="HelloSilverlight3.xap" /> <param name="width" value="300" /> <param name="height" value="100" /> <param name="onError" value="onSilverlightError" /> <param name="background" value="white" /> <param name="minRuntimeVersion" value="3.0.40624.0" /> <param name="autoUpgrade" value="true" /> <a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=3.0.40624.0" style="text-decoration: none"> <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style: none" /> </a> </object> </div> </asp:Content> <asp:Content ID="PageTitle" ContentPlaceHolderID="PlaceHolderPageTitle" runat="server"> Silverlight 3 Demo Application Page </asp:Content> <asp:Content ID="PageTitleInTitleArea" runat="server" ContentPlaceHolderID="PlaceHolderPageTitleInTitleArea"> Silverlight 3 Demo Application Page </asp:Content>InitParameters can be passed by using another <param> element. The value string is comma separated as it has always been:
<param name="initParams" value="key1=value,key2=value2" />The only disadvantage is that you have to click the Silverlight application before you can start interacting with it.
You can download the demo project here. Have fun with it!
Comments
Post a Comment