发布支持flash的 AdRotator C#版控件源码

 1 None.gif using  System;
 2 None.gif using  System.Web.UI;
 3 None.gif using  System.Web.UI.WebControls;
 4 None.gif using  System.ComponentModel;
 5 None.gif using  System.Text;
 6 None.gif namespace  FlashAdRotator
 7 ExpandedBlockStart.gifContractedBlock.gif dot.gif {
 8ExpandedSubBlockStart.gifContractedSubBlock.gif    /**//// <summary>
 9InBlock.gif    /// fpAdRotator 的摘要说明。
10ExpandedSubBlockEnd.gif    /// </summary>

11InBlock.gif    [DefaultProperty("Text"), 
12InBlock.gif        ToolboxData("<{0}:fpAdRotator runat=server></{0}:fpAdRotator>")]
13InBlock.gif    public class fpAdRotator : System.Web.UI.WebControls.AdRotator
14ExpandedSubBlockStart.gifContractedSubBlock.gif    dot.gif{
15InBlock.gif        private bool isflashad;
16InBlock.gif        private string imgurl;
17InBlock.gif        [Bindable(true), 
18InBlock.gif            Category("Appearance"), 
19InBlock.gif            DefaultValue("")] 
20ExpandedSubBlockStart.gifContractedSubBlock.gif        /**//// <summary> 
21InBlock.gif        /// 将此控件呈现给指定的输出参数。
22InBlock.gif        /// </summary>
23ExpandedSubBlockEnd.gif        /// <param name="output"> 要写出到的 HTML 编写器 </param>

24InBlock.gif        protected override void Render(HtmlTextWriter output)
25ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
26InBlock.gif            try
27ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
28InBlock.gif                if(isflashad==true)
29ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
30InBlock.gif                    StringBuilder sb=new StringBuilder("<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"");
31InBlock.gif                    sb.Append("codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width={0} height={1}>");
32InBlock.gif                    sb.Append("<param name=\"movie\" value={2} />");
33InBlock.gif                    sb.Append("<param name=\"quality\" value=\"high\"/>");
34InBlock.gif                    sb.Append("<embed src={3} quality=\"high\"");
35InBlock.gif                    sb.Append("pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width={4} height={5}></embed></object>");
36InBlock.gif                    StringBuilder outstr=new StringBuilder();
37InBlock.gif                    outstr.AppendFormat(sb.ToString(),this.Width,this.Height,this.imgurl,this.imgurl,this.Width,this.Height);
38InBlock.gif                    output.Write(outstr);
39ExpandedSubBlockEnd.gif                }

40InBlock.gif                if(isflashad==false)
41ExpandedSubBlockStart.gifContractedSubBlock.gif                dot.gif{
42InBlock.gif                    //this.Render(output);
43InBlock.gif                    base.Render (output);
44ExpandedSubBlockEnd.gif                }

45ExpandedSubBlockEnd.gif            }

46InBlock.gif            catch
47ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
48InBlock.gif                StringBuilder sb=new StringBuilder("<table><tr>广告媒体不存在<td></td></tr><table>");
49InBlock.gif                output.Write(sb);
50ExpandedSubBlockEnd.gif            }

51ExpandedSubBlockEnd.gif        }

52InBlock.gif        protected override void OnAdCreated(AdCreatedEventArgs e)
53ExpandedSubBlockStart.gifContractedSubBlock.gif        dot.gif{
54InBlock.gif            if(e.ImageUrl.ToLower().IndexOf(".swf")!=-1)
55ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
56InBlock.gif                this.isflashad=true;
57InBlock.gif                this.imgurl=e.ImageUrl;
58ExpandedSubBlockEnd.gif            }

59InBlock.gif            else
60ExpandedSubBlockStart.gifContractedSubBlock.gif            dot.gif{
61InBlock.gif                this.isflashad=false;
62ExpandedSubBlockEnd.gif            }

63ExpandedSubBlockEnd.gif        }

64ExpandedSubBlockEnd.gif    }

65ExpandedBlockEnd.gif}

66 None.gif
vs自带的AdRotator 不支持flash显示,而我又要用到这个功能,在网上搜罗了一阵,找到一个老外写的vb版本的,地址为: http://www.dnzone.com/ShowDetail.asp?NewsId=901。但我的项目都是用C#做的,索性自己改成C#的,思路是按照老外的走的,很简单的东西,这也是我第一个控件,谈不上原创,但是C#版的这个网上我还是没有找到。呵呵。编译环境 vs2003+window server 2003 。源码我已经测试通过。
  关于怎么使用的问题我就不说了,希望大家多多探讨!

转载于:https://www.cnblogs.com/devngm/archive/2007/06/18/787226.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值