本文共 1123 字,大约阅读时间需要 3 分钟。
using System;
using System.Web.UI;using System.Web.UI.WebControls;using System.ComponentModel;namespace blackflash{
/// <summary> /// Span 的摘要说明。 /// </summary> [DefaultProperty("Text"), ToolboxData("<{0}:Span runat=server></{0}:Span>")] public class Span : Control, IAttributeAccessor { private string text; [Bindable(true), Category("Appearance"), DefaultValue("")] public string Text { get { return text; }set
{ text = value; } } public String Class { get { return (String)ViewState["Class"]; } set { ViewState["Class"] = value; } } public void SetAttribute(String name, String value1) { ViewState[name] = value1; } public String GetAttribute(String name) { //Regex regex1 = new Regex("^.* " + name + "='([^']*)'.*$"); //return regex1.Replace(this.x233f092c536593eb, "$1");return (String)ViewState[name];
}/// <summary>
/// 将此控件呈现给指定的输出参数。 /// </summary> /// <param name="output"> 要写出到的 HTML 编写器 </param> protected override void Render(HtmlTextWriter output) { if (this.Class !=null) { output.Write("<span class='"+this.Class); output.Write("'>" + this.Text + " </span>"); } else { output.Write(this.Text); } } }}转载地址:http://dbptd.baihongyu.com/