silverlight 应用程序在ASP.NET Web网站或者Web应用程序里部署

1)新建ASP.NET Web应用程序,添加引用:

System.Web.Silverlight.dll

2)在页面上添加注册:

<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>

3)添加ScriptManager控件:

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

4)将xap文件添加到页面上:

<asp:Silverlight ID="Silverlight1" runat="server" Height="300px" Source="~/ClientBin/Ch4_ModalWindow.xap" Width="400px" />

5)代码实例如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SilverlightDeploy._Default" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
    <div>
    <asp:Silverlight ID="Silverlight1" runat="server" Height="300px" Source="~/ClientBin/Ch4_ModalWindow.xap" Width="400px" />
    </div>
    </form>
</body>
</html>

你可能感兴趣的:(Web,server,assembly,asp.net,asp,silverlight)