c# web 后台代码嵌入flash

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
namespace FlashPlayer
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string strWidth = "500";//the width of flash
            string strHeight = "200";//the height of flash
            string strPath = @"swf/50.swf";//the path of flash
            this.FindControl("ContentPanel").Controls.Add(new LiteralControl(ProduceFlashPlayer(strWidth,strHeight,strPath).ToString()));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        private StringBuilder ProduceFlashPlayer(string strWidth,string strHeight,string strPath)
        {
            StringBuilder sbFlashPlayer = new StringBuilder();
            string strFlashPlayerFormat="<object id='FlashID' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='{0}' height='{1}'>"
            + "<param name='movie' value='{2}' />"
            + "<param name='quality' value='high' />"
            + "<param name='wmode' value='opaque' />"
            + "<param name='swfversion' value='6.0.65.0' />"
            + "<param name='expressinstall' value='Scripts/expressInstall.swf' />"
            + "<!--[if !IE]>-->"
            + "<object type='application/x-shockwave-flash' data='{2}' width='{0}' height='{1}'>"
            + "<!--<![endif]-->"
            + "<param name='quality' value='high' />"
            + "<param name='wmode' value='opaque' />"
            + "<param name='swfversion' value='6.0.65.0' />"
            + "<param name='expressinstall' value='Scripts/expressInstall.swf' />"
            + "<div>"
            + "<p><a href='http://www.adobe.com/go/getflashplayer'><img src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='获取 Adobe Flash Player' width='112' height='33' /></a></p>"
            + "</div>"
            + "<!--[if !IE]>-->"
            + "</object>"
            + "<!--<![endif]-->"
            + "</object>"
            + "<script type='text/javascript'>"
            + "<!--"
            + "swfobject.registerObject('FlashID');"
            + "//-->"
            + "</script>";
            sbFlashPlayer.AppendFormat(strFlashPlayerFormat, strWidth, strHeight, strPath);
            return sbFlashPlayer;
        }
    }
}

你可能感兴趣的:(c# web 后台代码嵌入flash)