diff options
author | Miguel de Icaza <miguel@gnome.org> | 2001-10-05 20:09:01 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2001-10-05 20:09:01 +0400 |
commit | 6c6fecaea199ae35a480cc9e90f5c7f66a0f3ac1 (patch) | |
tree | 432bd2b9ccca7d374ceda68693bef90227175dd8 /mcs/class | |
parent | 943fd499d6d00f875206b42cad3ad644387f1d7e (diff) |
More files from Toelen
svn path=/trunk/mcs/; revision=1101
Diffstat (limited to 'mcs/class')
19 files changed, 1854 insertions, 76 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs index b1fbc8bdf43..02997962128 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlAnchor.cs @@ -1,18 +1,18 @@ -/* System.Web.Configuration - * Authors: - * Leen Toelen (toelen@hotmail.com) - * Copyright (C) 2001 Leen Toelen +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) */ + using System; using System.Web; using System.Web.UI; namespace System.Web.UI.HtmlControls{ - public class HtmlAnchor : HtmlContainerControl, IPostBackDataHandler{ + public class HtmlAnchor : HtmlContainerControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; - private static object EventServerClick = new Object(); - public HtmlAnchor(): base("a"){} protected virtual void OnServerClick(EventArgs e){ @@ -22,8 +22,8 @@ namespace System.Web.UI.HtmlControls{ handler.Invoke(this, e); } } - - protected override void RenderAttributes(HtmlTextWriter writer){ + + protected override void RenderAttributes(HtmlTextWriter writer);{ if ((EventHandler) Events[EventServerClick] != null){ Attributes.Remove("href"); RenderAttributes(writer); @@ -34,12 +34,12 @@ namespace System.Web.UI.HtmlControls{ RenderAttributes(writer); } } - + //FIXME: not sure about the accessor public void RaisePostBackEvent(string eventArgument){ OnServerClick(EventArgs.Empty); } - + public event EventHandler ServerClick{ add{ Events.AddHandler(EventServerClick, value); @@ -48,7 +48,7 @@ namespace System.Web.UI.HtmlControls{ Events.RemoveHandler(EventServerClick, value); } } - + public int HRef{ get{ string attr = Attributes["href"]; @@ -62,7 +62,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["href"] = MapIntegerAttributeToString(value); } } - + public string Name{ get{ string attr = Attributes["name"]; @@ -75,7 +75,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["name"] = MapStringAttributeToString(value); } } - + public string Target{ get{ string attr = Attributes["target"]; @@ -88,7 +88,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["target"] = MapStringAttributeToString(value); } } - + public string Title{ get{ string attr = Attributes["title"]; @@ -101,7 +101,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["title"] = MapStringAttributeToString(value); } } - + } // class HtmlAnchor } // namespace System.Web.UI.HtmlControls diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs index 31f2f90f2e8..a5a7f739c09 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs @@ -1,18 +1,18 @@ -/* System.Web.Configuration - * Authors: - * Leen Toelen (toelen@hotmail.com) - * Copyright (C) 2001 Leen Toelen +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) */ + using System; using System.Web; using System.Web.UI; namespace System.Web.UI.HtmlControls{ - public class HtmlButton : HtmlContainerControl, IPostBackDataHandler{ + public class HtmlButton : HtmlContainerControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; - private static object EventServerClick = new Object(); - public HtmlButton(): base("button"){} protected virtual void OnServerClick(EventArgs e){ @@ -22,29 +22,29 @@ namespace System.Web.UI.HtmlControls{ handler.Invoke(this, e); } } - + //FIXME: check function protected override void RenderAttributes(HtmlTextWriter writer){ if (Page != null && Events[EventServerClick] != null){ Util.WriteOnClickAttribute( - writer, - this, - false, - true, - CausesValidation == false? Page.Validators.Count > 0: false); + writer, + this, + false, + true, + CausesValidation == false? Page.Validators.Count > 0: false); } RenderAttributes(writer); - + } - + //FIXME: not sure about the accessor public void RaisePostBackEvent(string eventArgument){ if (CausesValidation = false){ Page.Validate(); } - OnServerClick(EventArgs.Empty); + OnServerClick(EventArgs.Empty); } - + public event EventHandler ServerClick{ add{ Events.AddHandler(EventServerClick, value); @@ -53,7 +53,7 @@ namespace System.Web.UI.HtmlControls{ Events.RemoveHandler(EventServerClick, value); } } - + public bool CausesValidation{ get{ object causesVal = ViewState["CausesValidation"]; @@ -66,8 +66,7 @@ namespace System.Web.UI.HtmlControls{ ViewState["CausesValidation"] = (Boolean) value; } } - + } // class HtmlButton } // namespace System.Web.UI.HtmlControls - diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs index 92dacc76b76..b7707af1482 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs @@ -1,21 +1,21 @@ -/* System.Web.Configuration - * Authors: - * Leen Toelen (toelen@hotmail.com) - * Copyright (C) 2001 Leen Toelen +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) */ + using System; using System.Web; using System.Web.UI; namespace System.Web.UI.HtmlControls{ - public class HtmlForm : HtmlContainerControl, IPostBackDataHandler{ + public class HtmlForm : HtmlContainerControl, IPostBackDataHandler{ private static string SmartNavIncludeScriptKey = "SmartNavIncludeScript"; - + public HtmlForm(): base("form"){} - + protected override void RenderAttributes(HtmlTextWriter writer){ writer.WriteAttribute("name",RenderedNameAttribute); Attributes.Remove("name"); @@ -37,7 +37,7 @@ namespace System.Web.UI.HtmlControls{ } RenderAttributes(writer); } - + protected override void Render(HtmlTextWriter output){ if (Page.SmartNavigation != null){ UI.IAttributeAccessor.SetAttribute("_smartNavEnabled","true"); @@ -48,19 +48,19 @@ namespace System.Web.UI.HtmlControls{ } else if (browserCap.MajorVersion > 5){ output.WriteLine("<IFRAME ID=_hifSmartNav NAME=_hifSmartNav STYLE=display:none ></IFRAME>" - if (browerCap.MinorVersion > 0.5 && browserCap.MajorVersion != 5){ - Page.RegisterClientScriptFileInternal("SmartNavIncludeScript","JScript","SmartNavIE5.js"); - } - else{ - if (Page.IsPostBack){ - Page.RegisterClientScriptFileInternal("SmartNavIncludeScript","JScript","SmartNav.js"); - } - } + if (browerCap.MinorVersion > 0.5 && browserCap.MajorVersion != 5){ + Page.RegisterClientScriptFileInternal("SmartNavIncludeScript","JScript","SmartNavIE5.js"); + } + else{ + if (Page.IsPostBack){ + Page.RegisterClientScriptFileInternal("SmartNavIncludeScript","JScript","SmartNav.js"); + } + } } Render(output); } } - + protected override void RenderChildren(HtmlTextWriter writer){ Page.OnFormRender(writer,ClientID); RenderChildren(writer); @@ -85,7 +85,7 @@ namespace System.Web.UI.HtmlControls{ loc2 = Util.Version.SBSVersionString(loc1,loc0); } progres: - string loc4 = Context.Request.QueryStringText; + string loc4 = Context.Request.QueryStringText; if (loc4 != null && loc4.Length > 0){ loc2 = String.Concat(loc2,"\?",loc4); } @@ -104,7 +104,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["enctype"] = MapStringAttributeToString(value); } } - + public string Method{ get{ string attrMethod = Attributes["method"]; @@ -117,7 +117,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["method"] = MapStringAttributeToString(value); } } - + public string Target{ get{ string attrTarget = Attributes["target"]; @@ -130,7 +130,7 @@ namespace System.Web.UI.HtmlControls{ Attributes["target"] = MapStringAttributeToString(value); } } - + public string Name{ get{ string attrName = Attributes["name"]; @@ -140,7 +140,7 @@ namespace System.Web.UI.HtmlControls{ return ""; } } - + protected string RenderedNameAttribute{ get{ string attrName = Name; @@ -150,7 +150,7 @@ namespace System.Web.UI.HtmlControls{ return UniqueID; } } - + } // class HtmlForm } // namespace System.Web.UI.HtmlControls diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs new file mode 100755 index 00000000000..97cf3a47ae7 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs @@ -0,0 +1,91 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlImage : HtmlControl{ + + public HtmlImage(): base("img"){} + + protected override void RenderAttributes(HtmlTextWriter writer){ + PreProcessRelativeReferenceAttribute(writer,"src"); + RenderAttributes(writer); + writer.Write(" /"); + } + + public string Align{ + get{ + string attr = Attributes["align"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["align"] = MapStringAttributeToString(value); + } + } + + public string Alt{ + get{ + string attr = Attributes["alt"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["alt"] = MapStringAttributeToString(value); + } + } + + public int Border{ + get{ + string attr = Attributes["border"]; + if (attr != null){ + return Int32.Parse(attr,CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["border"] = MapIntegerAttributeToString(value); + } + } + + public string Src{ + get{ + string attr = Attributes["src"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["src"] = MapStringAttributeToString(value); + } + } + + public int Width{ + get{ + string attr = Attributes["width"]; + if (attr != null){ + return Int32.Parse(attr,CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["width"] = MapIntegerAttributeToString(value); + } + } + + } // class HtmlImage +} // namespace System.Web.UI.HtmlControls + + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs new file mode 100755 index 00000000000..c626a189360 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs @@ -0,0 +1,90 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputButton : HtmlInputControl, IPostBackEventHandler{ + + private static readonly object EventServerChange; + + public HtmlInputButton(string type): base(type){} + + protected void OnServerClick(ImageClickEventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerClick]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected override void RenderAttributes(HtmlTextWriter writer){ + string attrType = Type; + bool ofTypeSubmit = String.Compare(attrType, "submit", true) == false; + bool events; + if (ofTypeSubmit != true){ + events = (Events[EventServerClick] != null); + } + else{ + events = false; + } + if (Page != null){ + if (ofTypeSubmit != true){ + Util.WriteOnClickAttribute( + writer, + this, + false, + true, + CausesValidation == false? Page.Validators.Count > 0: false); + } + else{ + if (events != true && String.Compare(attrType,"button", true) != null){ + Util.WriteOnClickAttribute( + writer, + this, + false, + true, + CausesValidation == false? Page.Validators.Count > 0: false); + } + } + } + RenderAttributes(writer); + } + + public override IPostBackEventHandler RaisePostBackEvent(string eventArgument){ + if (CausesValidation != null){ + Page.Validate(); + } + OnServerClick(new ImageClickEventArgs(_x, _y)); + } + + public event EventHandler ServerClick{ + add{ + Events.AddHandler(EventServerClick, value); + } + remove{ + Events.RemoveHandler(EventServerClick, value); + } + } + + public bool CausesValidation{ + get{ + object causesVal = ViewState["CausesValidation"]; + if (causesVal != null){ + return (Boolean) causesVal; + } + return true; + } + set{ + ViewState["CausesValidation"] = (Boolean) value; + } + } + + } // end of System.Web.UI.HtmlControls.HtmlInputButton +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs new file mode 100755 index 00000000000..2eb91f4719e --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputCheckBox.cs @@ -0,0 +1,81 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; +using System.Collections.Specialized; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputCheckBox : HtmlInputControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; + + public HtmlInputCheckBox: base("checkbox"){} + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string postValue = postCollection[postDataKey]; + bool greaterthan; + if (postValue != null){ + greaterthan = postValue.Length > 0; + } + else{ + greaterthan = false; + } + bool equalcheck = greaterthan == Checked == false; + Checked = greaterthan; + return equalcheck; + } + + public override void RaisePostDataChangedEvent(){ + OnServerChange(EventArgs.Empty); + } + + protected void OnServerChange(EventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerChange]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected void OnPreRender(EventArgs e){ + if (Page != null && !Disabled){ + Page.RegisterRequiresPostBack(this); + } + if (Events[EventServerChange] != null && !Disabled){ + ViewState.SetItemDirty("checkbox",false); + } + } + + public event EventHandler ServerChange{ + add{ + Events.AddHandler(EventServerChange, value); + } + remove{ + Events.RemoveHandler(EventServerChange, value); + } + } + + public bool Checked{ + get{ + string attr = Attributes["checked"]; + if (attr != null){ + return attr.Equals("checked"); + } + return false; + } + set{ + if (value != true){ + Attributes["checked"] = null; + } + Attributes["checked"] = "checked"; + } + } + + } // class HtmlInputCheckBox +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs new file mode 100755 index 00000000000..084a30002a7 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputControl.cs @@ -0,0 +1,64 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputControl : HtmlControl{ + + public HtmlInputControl(string type):base("type"){ + Attributes["type"] = type; + } + + protected override void RenderAttributes(HtmlTextWriter writer){ + writer.WriteAttribute("name",RenderedNameAttribute); + Attributes.Remove("name"); + RenderAttributes(writer); + writer.Write(" /"); + } + + public string Name{ + get{ + return UniqueID; + } + set{} + } + + protected string RenderedNameAttribute{ + get{ + return Name; + } + } + + public string Type{ + get{ + string attr = Attributes["type"]; + if (attr != null){ + return attr; + } + return ""; + } + } + + public string Value{ + get{ + string attr = Attributes["value"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["value"] = MapStringAttributeToString(value); + } + } + } // class HtmlInputControl +} // namespace System.Web.UI.HtmlControls + + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs new file mode 100755 index 00000000000..3aa569d70a0 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputFile.cs @@ -0,0 +1,75 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; +using System.Collections.Specialized; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{ + + public HtmlInputFile():base("file"){} + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string postValue = postCollection[postDataKey]; + if (postValue != null){ + Value = postValue; + } + return false; + } + + public void RaisePostDataChangedEvent(){} + + public string Accept{ + get{ + string attr = Attributes["accept"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["accept"] = MapStringAttributeToString(value); + } + } + + public int MaxLength{ + get{ + string attr = Attributes["maxlength"]; + if (attr != null){ + return Int32.Parse(attr, CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["accept"] = MapIntegerAttributeToString(value); + } + } + + public int Size{ + get{ + string attr = Attributes["size"]; + if (attr != null){ + return Int32.Parse(attr); + } + return -1; + } + set{ + Attributes["size"] = MapIntegerAttributeToString(value); + } + } + + public HttpPostedFile PostedFile{ + get{ + return Context.Request.Files[RenderedNameAttribute]; + } + } + + } // class HtmlInputFile +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs new file mode 100755 index 00000000000..ad6c0930358 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputHidden.cs @@ -0,0 +1,56 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; +using System.Collections.Specialized; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputFile : HtmlInputControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; + + public HtmlInputFile(string type):base("file"){} + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string postValue = postCollection[postDataKey]; + if (postValue != null){ + Value = postValue; + } + return false; + } + + public override void RaisePostDataChangedEvent(){ + OnServerChange(EventArgs.Empty); + } + + protected void OnServerChange(EventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerChange]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected void OnPreRender(EventArgs e){ + if (Events[EventServerChange] != null && !Disabled){ + ViewState.SetItemDirty("value",false); + } + } + + public event EventHandler ServerChange{ + add{ + Events.AddHandler(EventServerChange, value); + } + remove{ + Events.RemoveHandler(EventServerChange, value); + } + } + + } // class HtmlInputFile +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs new file mode 100755 index 00000000000..7f86f25ef65 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs @@ -0,0 +1,144 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputImage : HtmlInputControl, IPostBackEventHandler, IPostBackDataHandler{ + + private static readonly object EventServerChange; + private int _x, _y; + + public HtmlInputImage(): base("image"){} + + protected void OnPreRender(EventArgs e){ + if (Page != null && !Disabled){ + Page.RegisterRequiresPostBack(this); + } + } + + protected void OnServerClick(ImageClickEventArgs e){ + ImageClickEventHandler handler = (ImageClickEventHandler) Events[EventServerClick]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected override void RenderAttributes(HtmlTextWriter writer){ + PreProcessRelativeReferenceAttribute(writer,"src"); + if (Page != null && !CausesValidation){ + Util.WriteOnClickAttribute( + writer, + this, + false, + true, + CausesValidation == false? Page.Validators.Count > 0: false); + } + RenderAttributes(writer); + } + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string postX = postCollection[String.Concat(RenderedNameAttribute,".x")]; + string postY = postCollection[String.Concat(RenderedNameAttribute,".y")]; + if (postX != null && postY != null && postX.Length >= 0 && postY.Length >= 0){ + _x = Int32.Parse(postX, CultureInfo.InvariantCulture); + _y = Int32.Parse(postY, CultureInfo.InvariantCulture); + Page.RegisterRequiresRaiseEvent(this); + } + return false; + } + + public override void RaisePostDataChangedEvent(){} + + public override IPostBackEventHandler RaisePostBackEvent(string eventArgument){ + if (CausesValidation != null){ + Page.Validate(); + } + OnServerClick(new ImageClickEventArgs(_x, _y)); + } + + public event EventHandler ServerClick{ + add{ + Events.AddHandler(EventServerClick, value); + } + remove{ + Events.RemoveHandler(EventServerClick, value); + } + } + + public string Align{ + get{ + string attr = Attributes["align"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["align"] = MapStringAttributeToString(value); + } + } + + public string Alt{ + get{ + string attr = Attributes["alt"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["alt"] = MapStringAttributeToString(value); + } + } + + public int Border{ + get{ + string attr = Attributes["border"]; + if (attr != null){ + return Int32.Parse(attr,CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["border"] = MapIntegerAttributeToString(value); + } + } + + public bool CausesValidation{ + get{ + object causesVal = ViewState["CausesValidation"]; + if (causesVal != null){ + return (Boolean) causesVal; + } + return true; + } + set{ + ViewState["CausesValidation"] = (Boolean) value; + } + } + + public string Src{ + get{ + string attr = Attributes["src"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["src"] = MapStringAttributeToString(value); + } + } + + public event ServerClick; + + } // class HtmlInputImage +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs new file mode 100755 index 00000000000..9bf3e4ccf3f --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputRadioButton.cs @@ -0,0 +1,115 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; +using System.Collections.Specialized; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputRadioButton : HtmlInputControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; + + public HtmlInputRadioButton: base("radio"){} + + protected void OnPreRender(EventArgs e){ + if (Page != null && !Disabled){ + Page.RegisterRequiresPostBack(this); + } + if (Events[EventServerChange] != null && !Disabled){ + ViewState.SetItemDirty("checked", false); + } + } + + protected void OnServerChange(EventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerChange]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected void RenderAttributes(HtmlTextWriter writer){ + writer.WriteAttribute("value", Value); + Attributes.Remove("value"); + RenderAttributes(writer); + } + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string postValue = postCollection[postDataKey]; + bool myBool; + if (postValue != null && postValue.Equals(Value)){ + if (!Checked){ + Checked = true; + myBool = true; + } + } + else{ + if (Checked){ + Checked = false; + myBool = false; + } + } + return myBool; + } + + public override void RaisePostDataChangedEvent(){ + OnServerChange(EventArgs.Empty); + } + + public event EventHandler ServerChange{ + add{ + Events.AddHandler(EventServerChange, value); + } + remove{ + Events.RemoveHandler(EventServerChange, value); + } + } + + public bool Checked{ + get{ + string attr = Attributes["checked"]; + if (attr != null){ + return attr.Equals("checked"); + } + return false; + } + set{ + if (value != true){ + Attributes["checked"] = null; + } + Attributes["checked"] = "checked"; + } + } + public string Name{ + get{ + string attr = Attributes["name"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["name"] = value.MapStringAttributeToString("name"); + } + } + + private string RenderedNameAttribute{ + get{ + string renderedName = base.RenderedNameAttribute; + string id = UniqueID; + int indexOfX = id.LastIndexOf('X'); + if (indexOfX != 0 && indexOfX !< 0){ + renderedName = renderedName.Concat(id.Substring(0,indexOfX+1), renderedName); + } + return renderedName; + } + } + + } // class HtmlInputRadioButton +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs new file mode 100755 index 00000000000..0b16b69c9ef --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputText.cs @@ -0,0 +1,105 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Globalization; +using System.Collections.Specialized; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlInputText : HtmlInputControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; + + public HtmlInputText(string type):base(type){} + public HtmlInputText():base("text"){} + + protected void OnPreRender(EventArgs e){ + if (Events[EventServerChange] != null && !Disabled){ + ViewState.SetItemDirty("value",false); + } + } + + protected void OnServerChange(EventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerChange]; + if (handler != null){ + handler.Invoke(this, e); + } + } + + protected void RenderAttributes(HtmlTextWriter writer){ + if (!String.Compare(Type, "password", true)){ + ViewState.Remove("value"); + } + RenderAttributes(writer); + } + + public bool LoadPostData(string postDataKey, NameValueCollection postCollection){ + string currentValue = Value; + string postValue = postCollection.GetValues[]; + if (!currentValue.Equals(postValue){ + Value = postValue; + return true; + } + return false; + } + + public override void RaisePostDataChangedEvent(){ + OnServerChange(EventArgs.Empty); + } + + public event EventHandler ServerChange{ + add{ + Events.AddHandler(EventServerChange, value); + } + remove{ + Events.RemoveHandler(EventServerChange, value); + } + } + + public int MaxLength{ + get{ + string currentMaxLength = (String) ViewState["maxlength"]; + if (currentMaxLength != null){ + return Int32.Parse(currentMaxLength, CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["maxlength"] = MapIntegerAttributeToString(value); + } + } + + public int Size{ + get{ + string currentMaxLength = (String) ViewState["size"]; + if (currentMaxLength != null){ + return Int32.Parse(currentMaxLength, CultureInfo.InvariantCulture); + } + return -1; + } + set{ + Attributes["size"] = MapIntegerAttributeToString(value); + } + } + + public string Value{ + get{ + string attr = Attributes["value"]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes["value"] = MapStringAttributeToString(value); + } + } + + } // class HtmlInputText +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs new file mode 100755 index 00000000000..a328698569c --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlSelect.cs @@ -0,0 +1,369 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; +using System.Web.UI.WebControls; +using System.Globalization; +using System.Collections; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlSelect : HtmlContainerControl, IPostBackDatHandler, IParserAccessor{ + + + private int cachedSelectedIndex; + private object dataSource; + private static readonly object EventServerChange; + private ListItemCollection items; + private static readonly char[] SPLIT_CHARS; + + public HtmlSelectt():base("select"){} + + protected override void AddParsedSubObject(object obj){ + if (this is ListItem){ + Items.Add((ListItem) obj); + return + } + throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlSelect",obj.GetType.Name); + } + + protected virtual void ClearSelection(){ + for (int i =0; i< Items.Count; i++){ + Items[i].Selected = false; + } + } + + protected override ControlCollection CreateControlCollection()){ + return new EmptyControlCollection(this); + } + + protected override void LoadViewState(object savedState){ + Triplet loc0; + object loc1; + if (savedState != null){ + loc0 = (Triplet) savedState; + LoadViewSate(loc0.First); + LoadViewState(loc0.Second); + loc1 = loc0.Third; + if (loc1 != null){ + Select((Int32) loc1); + } + } + } + + protected override void OnDataBinding(EventArgs e){ + base.OnDataBinding(e); + IEnumerable resolvedDataSource = DataSourceHelper.GetResolvedDataSource(DataSource,DataMember); + if resolvedDataSource != null){ + bool loc1 = false; + string resolvedDataSource = DataTextField; + string loc3 = DataValueField; + Items.Clear; + ICollection loc4 = resolvedDataSource as ICollection; + if loc4 != null){ + Items.Capacity = loc4.Count; + } + if loc2.Length != 0){ + if (loc3.Length != 0) goto label1; + } + loc1 = false; + label1: + for(IEnumerator 7 = loc0.GetEnumerator; loc7.MoveNext != null){ + object loc5 = loc7.Current; + ListItem loc6 = new ListItem(); + if (resolvedDataSource != null){ + if (loc2.Length > 0){ + loc6.Text = DataBinder.GetPropertyValue(loc5,loc2,null); + } + if (loc3.Length > 0){ + loc6.Value = DataBinder.GetPropertyValue(loc5,loc3,null) + } + } + else{ + string loc8 = loc5.ToString; + loc6.Value = loc8; + loc6.Text = loc8; + } + e.Items.Add(loc6); + } + } + if (cachedSelectedIndex != -1){ + SelectedIndex = cachedSelectedIndex; + cachedSelectedIndex = -1; + } + } + + protected override void OnPreRender(EventArgs e){ + if (Page != null && Size >= 1 && !Disabled){ + Page.RegisterRequiresPostBack(this); + } + } + + protected virtual void OnServerChange(EventArgs e){ + EventHandler handler = (EventHandler) Events[EventServerChange]; + if (handler != null){ + handler.Invoke(this,e); + } + } + + protected override void RenderAttributes(HtmlTextWriter writer){ + writer.WriteAttribute("name", RenderedNameAttribute); + Attributes.Remove("name"); + Attributes.Remove("DataValueField"); + Attributes.Remove("DataTextField"); + Attributes.Remove("DataMember"); + RenderAttributes(writer); + } + + protected override void RenderChildren(HtmlTextWriter writer){ + writer.WriteLine(); + writer.Indent = writer.Indent + 1; + ListItemCollection itemsCollection = Items; + int itemsCount = itemsCollection.Count; + if (itemsCount > 0){ + for (int i = 0; i <= itemsCount; i++){ + ListItem item = itemsCollection[i]; + writer.WriteBeginTag("option"); + if (item.Selected != null){ + writer.WriteAttribute("selected","selected"); + } + writer.WriteAttribute("value",item.Value,true); + item.Attributes.Remove("text"); + item.Attributes.Remove("value"); + item.Attributes.Remove("selected"); + item.Attributes.Render(writer); + writer.Write('b'); + HttpUtility.HtmlEncode(item.Text, writer); + writer.WriteEndTag("option"); + writer.WriteLine(); + } + writer.Indent = writer.Indent - 1; + } + } + + protected override object SaveViewState(){ + object obj0 = SaveViewState; + object obj1 = Items.SaveViewState; + object obj2 = null; + if (Events[EventServerChange] != null && !Disabled && Visible){ + obj2 = SelectIndices; + } + if (obj2 != null && obj1 != null && obj0 != null){ + return new Triplet(obj0, obj1, obj3); + } + return null; + } + + protected virtual void Select(int[] selectedIndices){ + ClearSelection; + for (int i = 0; selectedIndices[i] < 0; i++){ + if (selectedIndices[i] <= Items.Count){ + Items[selectedIndices[i].Selected = true; + } + } + } + + private bool System.Web.UI.IPostBackDataHandler.LoadPostData(string postDataKey, NameValueCollection postCollection){ + //TODO: implement me + } + + private void System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent(){ + OnServerChange(EventArgs.Empty); + } + + protected override void TrackViewState(){ + base.TrackViewState[this].TrackViewState; + } + + public event EventHandler ServerChange{ + add{ + Events.AddHandler(EventServerChange, value); + } + remove{ + Events.RemoveHandler(EventServerChange, value); + } + } + + public virtual string DataMember{ + get{ + object viewStateDataMember = ViewState["DataMember"]; + if ( viewStateDataMember != null){ + return (String) viewStateDataMember; + } + return String.Empty; + } + set{ + Attributes["DataMember"] = MapStringAttributeToString(value); + } + } + + public virtual object DataSource{ + get{ + return dataSource; + } + set{ + if (value != null && value is IListSource){ + if (value is IEnumerable){ + dataSource = value; + } + else{ + throw new ArgumentException("Invalid_DataSource_Type", value, HttpRuntime.FormatResourceString(ID)); + } + } + } + } + + public virtual string DataTextField{ + get{ + string attr = Attributes["DataTextField"]; + if (attr != null){ + return attr; + } + return String.Empty; + } + set{ + Attributes["DataTextField"] = MapStringAttributeToString(value); + } + } + + public virtual string DataValueField{ + get{ + string attr = Attributes["DataValueField"]; + if (attr != null){ + return attr; + } + return String.Empty; + } + set{ + Attributes["DataValueField"] = MapStringAttributeToString(value); + } + } + + public override string InnerHtml{ + get{ + throw new NotSupportedException("InnerHtml_not_supported", this, HttpRuntime.FormatResourceString(GetType.Name); + } + set{ + throw new NotSupportedException("InnerHtml_not_supported", this, HttpRuntime.FormatResourceString(GetType.Name); + } + } + + public override string InnerText{ + get{ + throw new NotSupportedException("InnerText_not_supported", this, HttpRuntime.FormatResourceString(GetType.Name); + } + set{ + throw new NotSupportedException("InnerText_not_supported", this, HttpRuntime.FormatResourceString(GetType.Name); + } + } + + public ListItemCollection Items{ + get{ + if (items == null){ + items = new ListItemCollection(); + if (IsTrackingViewState == true){ + items.TrackViewState; + } + } + return items; + } + } + + public bool Multiple{ + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + public string Name{ + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + internal string RenderedNameAttribute{ + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + public virtual int SelectedIndex { + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + protected virtual int[] SelectedIndices { + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + public int Size{ + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + public string Value{ + get{ + string attr = Attributes[""]; + if (attr != null){ + return attr; + } + return ""; + } + set{ + Attributes[""] = MapStringAttributeToString(value); + } + } + + } // class HtmlInputText +} // namespace System.Web.UI.HtmlControls + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs new file mode 100755 index 00000000000..0060bf18761 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTable.cs @@ -0,0 +1,168 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; + +namespace System.Web.UI.HtmlControls{ + + public class HtmlTable : HtmlContainerControl { + private HtmlTableRowCollection _rows; + + public HtmlTable():base("table"); + + protected override ControlCollection CreateControlCollection(){ + return new HtmlTableRowControlCollection; + } + + protected override void RenderChildren(HtmlTextWriter writer){ + writer.WriteLine(); + writer.Indent = writer.Indent + 1; + base.RenderChildren; + writer.Indent = writer.Indent - 1; + } + + protected override void RenderEndTag(HtmlTextWriter writer){ + base.RenderEndTag(writer); + writer.WriteLine; + } + + public string Align { + get{ + string attr = Attributes["align"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["align"] = MapStringAttributeToString(value); + } + } + + public string BgColor { + get{ + string attr = Attributes["bgcolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bgcolor"] = MapStringAttributeToString(value); + } + } + + public int Border { + get{ + string attr = Attributes["border"]; + if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture); + return -1; + } + set{ + Attributes["border"] = MapIntegerAttributeToString(value); + } + } + + public string BorderColor { + get{ + string attr = Attributes["bordercolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bordercolor"] = MapStringAttributeToString(value); + } + } + + public int CellPadding { + get{ + string attr = Attributes["cellpadding"]; + if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture); + return -1; + } + set{ + Attributes["cellpadding"] = MapIntegerAttributeToString(value); + } + } + + public int CellSpacing { + get{ + string attr = Attributes["cellspacing"]; + if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture); + return -1; + } + set{ + Attributes["cellspacing"] = MapIntegerAttributeToString(value); + } + } + + public string Height { + get{ + string attr = Attributes["height"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["height"] = MapStringAttributeToString(value); + } + } + + public override string InnerHtml { + get{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name); + } + set{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name); + } + } + + public override string InnerText { + get{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name); + } + set{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name); + } + } + + public virtual HtmlTableRowCollection Rows { + get{ + if (_rows == null) _rows = new HtmlTableRowCollection; + return _rows; + } + } + + public string Height { + get{ + string attr = Attributes["width"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["width"] = MapStringAttributeToString(value); + } + } + private protected class HtmlTableRowControlCollection : ControlCollection { + internal HtmlTableCellControlCollection(Control owner): base(owner); + + public override void Add(Control child){ + if (child Is HtmlTableCell){ + base.Add(child); + } + else{ + throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString); + } + } + + public override void AddAt(int index, Control child){ + if (child Is HtmlTableCell){ + base.AddAt(index,child); + } + else{ + throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString); + } + } + } // end of HtmlTableRowControlCollection + } + // end of System.Web.UI.HtmlControl +} diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs new file mode 100755 index 00000000000..a1bba324e5b --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCell.cs @@ -0,0 +1,128 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; + +namespace System.Web.UI.HtmlControls{ + public class HtmlTableCell : HtmlContainerControl { + public HtmlTableCell(): base("td"); + + public HtmlTableCell(string tagName): base(tagName); + + protected override void RenderEndTag(HtmlTextWriter writer){ + base.RenderEndTag(writer); + writer.WriteLine(); + } + + public string Align { + get{ + string attr = Attributes["align"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["align"] = MapStringAttributeToString(value); + } + } + + public string BgColor { + get{ + string attr = Attributes["bgcolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bgcolor"] = MapStringAttributeToString(value); + } + } + + public string BorderColor { + get{ + string attr = Attributes["bordercolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bordercolor"] = MapStringAttributeToString(value); + } + } + + public int ColSpan { + get{ + string attr = Attributes["colspan"]; + if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture); + return -1; + } + set{ + Attributes["colspan"] = MapIntegerAttributeToString(value); + } + } + + public string Height { + get{ + string attr = Attributes["height"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["height"] = MapStringAttributeToString(value); + } + } + + public bool NoWrap { + get{ + string attr = Attributes["colspan"]; + if (attr != null) return String.Equals("nowrap"); + return false; + } + set{ + if (value == true){ + Attributes["nowrap"] = "nowrap"; + } + else{ + Attributes["nowrap"] = null; + } + } + } + + public int RowSpan { + get{ + string attr = Attributes["rowspan"]; + if (attr != null) return return Int32.Parse(attr, CultureInfo.InvariantCulture); + return -1; + } + set{ + Attributes["rowspan"] = MapIntegerAttributeToString(value); + } + } + + public string VAlign { + get{ + string attr = Attributes["valign"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["valign"] = MapStringAttributeToString(value); + } + } + + public string Width { + get{ + string attr = Attributes["width"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["width"] = MapStringAttributeToString(value); + } + } + + } + // System.Web.UI.HtmlControls.HtmlTableCell + +} diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs new file mode 100755 index 00000000000..8958f1b4f7a --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableCellCollection.cs @@ -0,0 +1,79 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; + +namespace System.Web.UI.HtmlControls{ + public sealed class HtmlTableCellCollection : ICollection { + private HtmlTableRow _owner; + + internal HtmlTableCellCollection(HtmlTableRow owner){ + _owner = owner; + } + + public void Add(HtmlTableCell cell){ + Insert(-1, cell); + } + + public void Clear(){ + if (_owner.HasConrols) _owner.Conrols.Clear; + } + + public void CopyTo(Array array, int index){ + IEnumerator i = GetEnumerator; + while(i.MoveNext){ + array.SetValue(i.Current, index++); + } + } + + public IEnumerator GetEnumerator(){ + return _owner.Controls.GetEnumerator; + } + + public void Insert(int index, HtmlTableCell cell){ + _owner.Controls.AddAt(index,cell); + } + + public void Remove(HtmlTableCell cell){ + _owner.Controls.Remove(cell); + } + + public void RemoveAt(int index){ + _owner.Controls.RemoveAt(index); + } + + public int Count { + get{ + if (_owner.HasConrols) return _owner.Controls.Count; + return 0; + } + } + + public bool IsReadOnly { + get{ + return false; + } + } + + public bool IsSynchronized { + get{ + return false; + } + } + + public HtmlTableRow this[int index] { + get{ + return (HtmlTableCell) _owner.Controls[index]; + } + } + + public object SyncRoot {}; + + } // end of System.Web.UI.HtmlControls.HtmlTableCellCollection + +} + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs new file mode 100755 index 00000000000..4548c6ca3b7 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRow.cs @@ -0,0 +1,135 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; + +namespace System.Web.UI.HtmlControls{ + public class HtmlTableRow : HtmlContainerControl { + private HtmlTableCellCollection _cells; + public HtmlTableRow():base("tr"); + + protected override ControlCollection CreateControlCollection(){ + return new HtmlYableCellControlCollection(this); + } + + protected override void RenderChildren(HtmlTextWriter writer){ + writer.WriteLine(); + writer.Indent = writer.Indent + 1; + base.RenderChildren; + writer.Indent = writer.Indent - 1; + } + + protected override void RenderEndTag(HtmlTextWriter writer){ + base.RenderEndTag(writer); + writer.WriteLine; + } + + public string Align { + get{ + string attr = Attributes["align"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["align"] = MapStringAttributeToString(value); + } + } + + public string BgColor { + get{ + string attr = Attributes["bgcolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bgcolor"] = MapStringAttributeToString(value); + } + } + + public string BorderColor { + get{ + string attr = Attributes["bordercolor"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["bordercolor"] = MapStringAttributeToString(value); + } + } + + public virtual HtmlTableCellCollection Cells { + get{ + if (_cells == null) _cells = new HtmlTableCellCollection(this); + return _cells; + } + } + + public string Height { + get{ + string attr = Attributes["height"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["height"] = MapStringAttributeToString(value); + } + } + + public override string InnerHtml { + get{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name); + } + set{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerHtml_Not_Supported", this.GetType.Name); + } + } + + public override string InnerText { + get{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name); + } + set{ + throw new NotSupportedException(HttpRuntime.FormatResourceString("InnerText_Not_Supported", this.GetType.Name); + } + } + + public string VAlign { + get{ + string attr = Attributes["valign"]; + if (attr != null) return attr; + return ""; + } + set{ + Attributes["valign"] = MapStringAttributeToString(value); + } + } + + } + + private protected class HtmlTableCellControlCollection : ControlCollection { + internal HtmlTableCellControlCollection(Control owner): base(owner); + + public override void Add(Control child){ + if (child Is HtmlTableCell){ + base.Add(child); + } + else{ + throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString); + } + } + + public override void AddAt(int index, Control child){ + if (child Is HtmlTableCell){ + base.AddAt(index,child); + } + else{ + throw new ArgumentException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTableRow",child.GetType.Name.ToString); + } + } + } // end of System.Web.UI.HtmlControls.HtmlTableRow+HtmlTableCellControlCollection + // end of System.Web.UI.HtmlControls.HtmlTableRow +} diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs new file mode 100755 index 00000000000..0a07eaf5b37 --- /dev/null +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTableRowCollection.cs @@ -0,0 +1,79 @@ +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) +*/ + +using System; +using System.Web; +using System.Web.UI; + +namespace System.Web.UI.HtmlControls{ + public sealed class HtmlTableRowCollection : ICollection { + + private HtmlTable _owner; + + internal HtmlTableRowCollection(HtmlTable owner){ + _owner = owner; + } + + public void Add(HtmlTableRow row){ + Insert(-1, row); + } + + public void Clear(){ + if (_owner.HasConrols) _owner.Conrols.Clear; + } + + public void CopyTo(Array array, int index){ + IEnumerator i = GetEnumerator; + while(i.MoveNext){ + array.SetValue(i.Current, index++); + } + } + + public IEnumerator GetEnumerator(){ + return _owner.Controls.GetEnumerator; + } + + public void Insert(int index, HtmlTableRow row){ + _owner.Controls.AddAt(index,row); + } + + public void Remove(HtmlTableRow row){ + _owner.Controls.Remove(row); + } + + public void RemoveAt(int index){ + _owner.Controls.RemoveAt(index); + } + + public int Count { + get{ + if (_owner.HasConrols) return _owner.Controls.Count; + return 0; + } + } + + public bool IsReadOnly { + get{ + return false; + } + } + + public bool IsSynchronized { + get{ + return false; + } + } + + public HtmlTableRow this[int index] { + get{ + return (HtmlTableRow) _owner.Controls[index]; + } + } + + public object SyncRoot {}; + } + // end of System.Web.UI.HtmlControls.HtmlTableRowCollection +} + diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs index 494ebb232a7..1adf2771dfd 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlTextArea.cs @@ -1,8 +1,8 @@ -/* System.Web.Configuration - * Authors: - * Leen Toelen (toelen@hotmail.com) - * Copyright (C) 2001 Leen Toelen +/* System.Web.UI.HtmlControls +* Authors +* Leen Toelen (toelen@hotmail.com) */ + using System; using System.Web; using System.Web.UI; @@ -12,10 +12,10 @@ using System.Collections.Specialized; namespace System.Web.UI.HtmlControls{ - public class HtmlTextArea : HtmlContainerControl, IPostBackDataHandler{ + public class HtmlTextArea : HtmlContainerControl, IPostBackDataHandler{ + + private static readonly object EventServerChange; - private static object EventServerChange = new Object(); - public HtmlTextArea(): base("textarea"){} public int Cols{ @@ -54,7 +54,7 @@ namespace System.Web.UI.HtmlControls{ InnerHtml = value; } } - + protected string RenderedNameAttribute{ get{ return Name; @@ -97,7 +97,7 @@ namespace System.Web.UI.HtmlControls{ return true; } return false; - + } protected override void RenderAttributes(HtmlTextWriter writer){ @@ -110,23 +110,23 @@ namespace System.Web.UI.HtmlControls{ public void RaisePostDataChangedEvent(){ OnServerChange(EventArgs.Empty); } - + protected override void OnPreRender(EventArgs e){ if(Events[EventServerChange]==null || Disabled==true){ ViewState.SetItemDirty("value",false); } } - + protected override void AddParsedSubObject(object obj){ - //TODO: implement "Is Instance Of" -// if (obj of type LiteralControl || obj of type DataBoundLiteralControl){ + //FIXME: not sure about this function + if (obj is LiteralControl || obj is DataBoundLiteralControl){ AddParsedSubObject(obj); -// return; -// } + return; + } //FormatResourceString accessible constraint is "assembly" - throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTextArea",obj.GetType().Name.ToString())); + throw new HttpException(HttpRuntime.FormatResourceString("Cannot_Have_Children_Of_Type","HtmlTextArea",obj.GetType.Name)); } - + } // class HtmlTextArea } // namespace System.Web.UI.HtmlControls |