加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

播放Flash的用户控件

发布时间:2020-12-15 18:26:45 所属栏目:百科 来源:网络整理
导读:1、创建一个用户控件 SwfPlayer.ascx %@ Control Language="C#" AutoEventWireup="true" CodeFile="SwfPlayer.ascx.cs" Inherits="SwfPlayer" % 后台代码: using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using

1、创建一个用户控件 SwfPlayer.ascx

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SwfPlayer.ascx.cs" Inherits="SwfPlayer" %>

后台代码:

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

public partial class SwfPlayer : System.Web.UI.UserControl
{
??? private string _File;
??? private int _Width;
??? private int _Height;

??? //设置Flash宽度属性
??? public int Width
??? {
??????? set { _Width = value; }
??? }

??? //设置Flash高度属性
??? public int Height
??? {
??????? set { _Height = value; }
??? }

??? //Flash文件
??? public string File
??? {
??????? set { _File = value; }
??? }

??? protected void Page_Load(object sender,EventArgs e)
??? {
??? }

??? //重新Render方法
??? protected override void Render(HtmlTextWriter writer)
??? {
??????? //Flash对象
??????? StringBuilder sb = new StringBuilder();
??????? sb.AppendFormat("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,19,0'width='{0}' height='{1}'>",_Width,_Height);
??????? sb.AppendFormat("<param name='movie' value='{0}'>",_File);
??????? sb.AppendFormat("<param name='quality' value='high'>");
??????? sb.AppendFormat("<embed src='{0}' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='{1}' height='{2}'></embed>",_File,_Height);
??????? sb.Append("</object>");
??????? writer.Write(sb.ToString());
??? }

}

?

2、引用页面

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="SwfPlayPage.aspx.cs" Inherits="SwfPlayPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Register Src="SwfPlayer.ascx" TagName="SwfPlayer" TagPrefix="uc1" %>

<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> ??? <title></title> </head> <body> ??? <form id="form1" runat="server"> ??? <div> ??????? <uc1:SwfPlayer ID="SwfPlayer1" runat="server" File="Files/photo.swf" Width="400" Height="300"?/> ??? </div> ??? </form> </body> </html>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读