mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 01:41:17 -10:00
* System.Web.UI/AttributeCollection.cs: don't need a Hastable. StateBag now works fine and takes care of the details. * System.Web.UI/Control.cs: added HasChildren property. * System.Web.UI/StateBag.cs: fixed a couple of nasty bugs. * System.Web.UI.HtmlControls/HtmlButton.cs: RenderAttributes is an override, not new. * System.Web.UI.HtmlControls/HtmlContainerControl.cs: use the new Render method in HtmlControl. * System.Web.UI.HtmlControls/HtmlControl.cs: added Render method to render the tag and its attributes. Works for container and non-containers. * System.Web.UI.HtmlControls/HtmlImage.cs: RenderAttributes don't need to be new. Implemented Height property. svn path=/trunk/mcs/; revision=5130
114 lines
2.3 KiB
C#
114 lines
2.3 KiB
C#
//
|
|
// System.Web.UI.HtmlControls.HtmlControl.cs
|
|
//
|
|
// Author
|
|
// Bob Smith <[email protected]>
|
|
//
|
|
//
|
|
// (C) Bob Smith
|
|
//
|
|
|
|
using System;
|
|
using System.Globalization;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
|
|
namespace System.Web.UI.HtmlControls{
|
|
|
|
public abstract class HtmlControl : Control, IAttributeAccessor
|
|
{
|
|
private string _tagName = "span";
|
|
//TODO: Is this correct, or is the StateBag really the ViewState?
|
|
private AttributeCollection _attributes = new AttributeCollection(new StateBag(true));
|
|
private bool _disabled = false;
|
|
|
|
public HtmlControl(){}
|
|
|
|
public HtmlControl(string tag)
|
|
{
|
|
if(tag != null && tag != String.Empty) _tagName = tag;
|
|
}
|
|
|
|
internal static string AttributeToString(int n){
|
|
if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
|
|
return null;
|
|
}
|
|
|
|
internal static string AttributeToString(string s){
|
|
if (s != null && s.Length != 0) return s;
|
|
return null;
|
|
}
|
|
|
|
internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
|
|
string attr = Attributes[attribName];
|
|
if (attr != null){
|
|
if (attr.Length != 0){
|
|
try{
|
|
attr = ResolveUrl(attr);
|
|
}
|
|
catch (Exception e) {
|
|
throw new HttpException(attribName + " property had malformed url");
|
|
}
|
|
writer.WriteAttribute(attribName, attr);
|
|
Attributes.Remove(attribName);
|
|
}
|
|
}
|
|
}
|
|
|
|
string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
|
|
return Attributes[name];
|
|
}
|
|
|
|
void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
|
|
Attributes[name] = value;
|
|
}
|
|
|
|
protected override void Render (HtmlTextWriter writer)
|
|
{
|
|
writer.WriteBeginTag (TagName);
|
|
RenderAttributes (writer);
|
|
writer.Write ('>');
|
|
}
|
|
|
|
protected virtual void RenderAttributes(HtmlTextWriter writer){
|
|
if (ID != null){
|
|
writer.WriteAttribute("id",ClientID);
|
|
}
|
|
Attributes.Render(writer);
|
|
}
|
|
|
|
public AttributeCollection Attributes
|
|
{
|
|
get
|
|
{
|
|
return _attributes;
|
|
}
|
|
}
|
|
public bool Disabled
|
|
{
|
|
get
|
|
{
|
|
return _disabled;
|
|
}
|
|
set
|
|
{
|
|
_disabled = value;
|
|
}
|
|
}
|
|
public CssStyleCollection Style
|
|
{
|
|
get
|
|
{
|
|
return _attributes.CssStyle;
|
|
}
|
|
}
|
|
public virtual string TagName
|
|
{
|
|
get
|
|
{
|
|
return _tagName;
|
|
}
|
|
}
|
|
}
|
|
}
|