日期:2014-05-17  浏览次数:20397 次

关于字符串转换的小问题
<embed id="youkuplayer" align="middle" width="640" src="http://player.youku.com/player.php/sid/XNTE1Mzg5MzA4/v.swf?showAd=0&winType=interior&isShowRelatedVideo=false&isAutoPlay=true" quality="1" height="480" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" play="true" menu="true" loop="true"></embed>

这是一串要嵌在页面里面的youku视频代码,SRC里面的内容用HtmlGenericControl.Attributes.Add方法动态填充,
如:
youkuplayer.Attributes.Add("src", "http://player.youku.com/player.php/sid/" + rxid + "/v.swf?showAd=0&winType=interior&isShowRelatedVideo=false&isAutoPlay=true");
但是填充内容当中包含字符&,填充上去在HTML里面&显示成&amp;这样的乱码而导致视频无法正常播放,在字符串那里怎么设置才能确保在HTML代码中正确显示&这个字符呢?谢谢

------解决方案--------------------

 ClientScript.RegisterStartupScript(this.GetType(), "", "<script>document.getElementById('youkuplayer').src='...';</script>");