以编程方式向asp.net页添加.swf的最佳方法是什么? [英] Whats the best way to programatically add a .swf to an asp.net page?

查看:85
本文介绍了以编程方式向asp.net页添加.swf的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种好的方法可以以编程方式将.swf添加到asp.net页上的面板上-即:我知道我可以插入html标签:

Is there a good way to add a .swf programatically to a panel on an asp.net page - ie: I know i could just insert the html tags:

ie:

<object type="application/x-shockwave-flash" data="yourflash.swf" width="" height="">
<param name="movie" value="yourflash.swf">
</object>

但是是否已经存在一个仅用于设置属性的.net或免费FLASH组件,或者我需要自己创建一个自定义的Web控件(不是首选),这样我就不必继续这样做吗?

But is there an existing .net or free FLASH component already that you just set the properties on, or do i need to create a custom web control myself (not preferred) so i dont have to continously do this?

谢谢。

推荐答案

FlashObject.cs

namespace MyNamespace 
{ 
 using System.Web.UI;

 public class FlashObject : Control
 { public int Width  {get;set}
   public int Height {get;set}
   [UrlProperty] pubic string SourceUrl {get;set;}

   protected override Render(HtmlWriter writer)
    { writer.WriteLine( "<object type='application/x-shockwave-flash' "
                       +" data='{0}' width='{1}' height='{2}'>\r\n"
                       +"    <param name='movie' value='{0}'>\r\n</object>"
                       ,ResolveUrl(SourceUrl)
                       ,Width
                       ,Height);
    }
 }
}

Web.config

  <system.web> 
     <controls>
       <add tagPrefix="my" namespace="MyNamespace" assembly="MyAssembly" />
     </controls>
  </system.web>

MyPage.aspx

 <my:FlashObject SourceUrl='~/yourflash.swf' runat='server' />

这篇关于以编程方式向asp.net页添加.swf的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆