asp.net项目引用silverlight插件

其实很简单,silverlight4中,只需要新建一个silverlight项目,找到启动的aspx或html页面,复制引用代码到asp.net项目的aspx即可,同时在项目中引用silverlight项目下的silverlight.js.说实话.其实在这个方面现在来说两者是一样的,目前发现区别在于启动方式?silverlight需要加载一个xaml启动,asp.net则不需要,可以做到加载多个xaml的效果,从跟html兼容这方面来说,效果要比用silverlight项目好.

引用代码:

script部分:

<script type="text/javascript" src="Silverlight.js"></script>
<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">
<object width="50%" height="50%"
type="application/x-silverlight-2"
data="data:application/x-silverlight-2," >
<param name="source" value="SilverlightApplication1.xap"/>
<param name="onerror" value="onSilverlightError" />
<param name="background" value="white" />
<param name="minRuntimeVersion" value="4.0.50826.0" />
<param name="autoUpgrade" value="true" />
<a href="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.60310.0"
style="text-decoration: none;">
<img
src="http://go.microsoft.com/fwlink/?LinkId=161376"
alt="Get Microsoft Silverlight"
style="border-style: none"/>
</a>
</object>
<iframe id="_sl_historyFrame"
style=‘visibility:hidden;height:0px;width:0px;border:0px‘>
</iframe>
</div>

 

小白一枚,欢迎讨论

asp.net项目引用silverlight插件,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。