📄 htmlcontrol.cs
字号:
using System;
using System.Web.UI;
using System.Globalization;
namespace System.Web.UI.HtmlControls
{
/// <summary>
/// Summary description for HtmlControl.
/// </summary>
//.custom instance void [System]System.ComponentModel.DesignerAttribute
//.custom instance void [System]System.ComponentModel.ToolboxItemAttribute
public abstract class HtmlControl : Control,IAttributeAccessor
{
private AttributeCollection _attributes;
internal string _tagName;
public HtmlControl()
{
// this = new System.Web.UI.HtmlControls.HtmlControl("span");
}
public HtmlControl(string tag) : base()
{
this._tagName = tag;
}
protected virtual ControlCollection CreateControlCollection()
{
return new EmptyControlCollection(this);
}
internal static string MapIntegerAttributeToString(int n)
{
if (n == -1)
return null;
return n.ToString(NumberFormatInfo.InvariantInfo);
}
internal static string MapStringAttributeToString(string s)
{
if (s != null && s.Length == 0)
return null;
return s;
}
internal void PreProcessRelativeReferenceAttribute(HtmlTextWriter writer, string attribName)
{
string local0;
local0 = this.Attributes[attribName];
if (local0 == null || local0.Length == 0)
return;
try
{
local0 = this.ResolveUrl(local0);
}
catch (Exception local1)
{
throw new HttpException(System.Web.HttpRuntime.FormatResourceString("Property_Had_Malformed_Url", attribName, local1.Message));
}
writer.WriteAttribute(attribName, local0);
this.Attributes.Remove(attribName);
}
protected virtual void Render(HtmlTextWriter writer)
{
this.RenderBeginTag(writer);
}
protected virtual void RenderAttributes(HtmlTextWriter writer)
{
if (this.ID != null)
writer.WriteAttribute("id", this.ClientID);
this.Attributes.Render(writer);
}
protected virtual void RenderBeginTag(HtmlTextWriter writer)
{
writer.WriteBeginTag(this.TagName);
this.RenderAttributes(writer);
writer.Write('>');
}
string System.Web.UI.IAttributeAccessor.GetAttribute(string name)
{
return this.Attributes[name];
}
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value)
{
this.Attributes[name]= value;
}
public AttributeCollection Attributes
{
get
{
if (this._attributes == null)
this._attributes = new AttributeCollection(this.ViewState);
return this._attributes;
}
}
public bool Disabled
{
get
{
string local0;
local0 = this.Attributes["disabled"];
if (local0 == null)
return false;
return local0 == "disabled";
}
set
{
if (value)
{
this.Attributes["disabled"]= "disabled";
return;
}
this.Attributes["disabled"]= null;
}
}
public CssStyleCollection Style
{
get
{
return this.Attributes.CssStyle;
}
}
public virtual string TagName
{
get
{
return this._tagName;
}
}
protected virtual bool ViewStateIgnoresCase
{
get
{
return true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -