码迷,mamicode.com
首页 > Web开发 > 详细

asp.net项目引用silverlight插件

时间:2014-05-17 13:04:20      阅读:368      评论:0      收藏:0      [点我收藏+]

标签:style   code   c   java   ext   http   

其实很简单,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插件,布布扣,bubuko.com

asp.net项目引用silverlight插件

标签:style   code   c   java   ext   http   

原文地址:http://www.cnblogs.com/yastar/p/3724873.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!