博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义控件Img
阅读量:2727 次
发布时间:2019-05-13

本文共 2165 字,大约阅读时间需要 7 分钟。

using System;

using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

namespace blackflash{

 /// <summary>
 /// Img 的摘要说明。
 /// </summary>
 [DefaultProperty("Text"),
 ToolboxData("<{0}:Img runat=server></{0}:Img>")]
 public class Img : Control, IAttributeAccessor
 {
  [Bindable(true),
  Category("Appearance"),
  DefaultValue("")]
  public String Src
  {
   get
   {
    return (String)ViewState["Src"];
   }
   set
   {
    ViewState["Src"] = value;
   }
  }
  public String Href
  {
   get
   {
    return (String)ViewState["Href"];
   }
   set
   {
    ViewState["Href"] = value;
   }
  }
  public String Align
  {
   get
   {
    return (String)ViewState["align"];
   }
   set
   {
    ViewState["align"] = value;
   }
  }
  public String Alpha
  {
   get
   {
    return (String)ViewState["alpha"];
   }
   set
   {
    ViewState["alpha"] = value;
   }
  }
  public String Target
  {
   get
   {
    return (String)ViewState["Target"];
   }
   set
   {
    ViewState["Target"] = value;
   }
  }
  public void SetAttribute(String name, String value1)
  {
   ViewState[name] = value1;
  }
  public String GetAttribute(String name)
  {
   return (String)ViewState[name];
  }

  /// <summary>

  /// 将此控件呈现给指定的输出参数。
  /// </summary>
  /// <param name="output"> 要写出到的 HTML 编写器 </param>
  protected override void Render(HtmlTextWriter output)
  {
   if (this.Src !="")
   {
   
    if (this.Href !=null)
    {
     output.Write("<a");
     output.Write(" href='"+this.Href+"'");
     if (this.Target !=null)
     {
      output.Write(" target='"+this.Target+"'");
     }
     output.Write(">");
    }    
    output.Write("<img ");   
    if (this.Src !=null)
    {
     output.Write("src='"+this.Src+"'");
    }

    if (this.Alpha !=null)

    {
     string[] strAlpha = this.Alpha.Split(',');
     output.Write("style='filter:alpha(opacity="+strAlpha[0]+")' οnmοuseοver='this.filters.Alpha.opacity=/""+strAlpha[1]+"/"' οnmοuseοut='this.filters.Alpha.opacity=/""+strAlpha[0]+"/"' ");
    }
    if (this.Align !=null)
    {
     output.Write(" align='"+this.Align+"'");
    }
    if ((String)ViewState["style"] != null)
    {
     output.Write(" style='"+(String)ViewState["style"]+"'");
    }
    if ((String)ViewState["width"] != null)
    {
     output.Write(" width='"+(String)ViewState["width"]+"'");
    }
    if ((String)ViewState["height"] != null)
    {
     output.Write(" height='"+(String)ViewState["height"]+"'");
    }
    output.Write(" border='0' />");
    if (this.Href !=null)
    {
     output.Write("</a>");
    }
   }
  }
 }
}

转载地址:http://bbptd.baihongyu.com/

你可能感兴趣的文章
《CBAM: Convolutional Block Attention Module》论文笔记
查看>>
《A Transductive Approach for Video Object Segmentation》论文笔记
查看>>
《TDNet:Temporally Distributed Networks for Fast Video Semantic Segmentation》论文笔记
查看>>
《HRank:Filter Pruning using High-Rank Feature Map》论文笔记
查看>>
《Siamese FC:Fully-Convolutional Siamese Networks for Object Tracking》论文笔记
查看>>
《FRTM:Learning Fast and Robust Target Models for Video Object Segmentation》论文笔记
查看>>
《STM:Video Object Segmentation using Space-Time Memory Networks》论文笔记
查看>>
《Non-local Neural Networks》论文笔记
查看>>
Pytorch中torch.nn.DataParallel负载均衡问题
查看>>
《FPGM:Filter Pruning via Geometric Median for Deep Convolutional Neural Networks Acceleration》论文笔记
查看>>
《Siamese RPN:High Performance Visual Tracking with Siamese Region Proposal Network》论文笔记
查看>>
《OpenPose:Realtime Multi-Person 2D Pose Estimation using Part Affinity Fields》论文笔记
查看>>
《RETHINKING THE VALUE OF NETWORK PRUNING》论文笔记
查看>>
《Real-time 2D Multi-Person Pose Estimation on CPU:Lightweight OpenPose》论文笔记
查看>>
《Decoders Matter for Semantic Segmentation》论文笔记
查看>>
《HRNet:Deep High-Resolution Representation Learning for Human Pose Estimation》论文笔记
查看>>
《HigherHRNet:Scale-Aware Representation Learning for Bottom-Up Human Pose Estimation》论文笔记
查看>>
《PackNet:3D Packing for Self-Supervised Monocular Depth Estimation》论文笔记
查看>>
《EfficientNetV2:Smaller Models and Faster Training》论文笔记
查看>>
深度估计 DenseDepth 笔记
查看>>