Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs/class
diff options
context:
space:
mode:
authorGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2002-06-05 19:58:32 +0400
committerGonzalo Paniagua Javier <gonzalo.mono@gmail.com>2002-06-05 19:58:32 +0400
commit62aeab6dc17ed33644f8da189b788c2339648f4e (patch)
treea40651d92c5bc9a05863363b71e21edd87634584 /mcs/class
parenta6e91ebb095fc3eb19b6350972bf5361353dd18c (diff)
2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* 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
Diffstat (limited to 'mcs/class')
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog12
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs8
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs4
-rw-r--r--mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs39
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs17
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs31
-rwxr-xr-xmcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs12
-rwxr-xr-xmcs/class/System.Web/System.Web.UI/AttributeCollection.cs31
-rw-r--r--mcs/class/System.Web/System.Web.UI/ChangeLog9
-rw-r--r--mcs/class/System.Web/System.Web.UI/Control.cs6
-rw-r--r--mcs/class/System.Web/System.Web.UI/StateBag.cs18
11 files changed, 72 insertions, 115 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
index 465d0492174..d5a0b7868df 100644
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog
@@ -1,5 +1,17 @@
2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+ * HtmlButton.cs: RenderAttributes is an override, not new.
+
+ * HtmlContainerControl.cs: use the new Render method in HtmlControl.
+
+ * HtmlControl.cs: added Render method to render the tag and its
+ attributes. Works for container and non-containers.
+
+ * HtmlImage.cs: RenderAttributes don't need to be new. Implemented
+ Height property.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
* HtmlContainerControl.cs: some formatting and use HttpUtility.Encode
instead of Page.Server to encode InnerText.
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 640daf02fef..b926ef0f184 100644
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlButton.cs
@@ -29,13 +29,9 @@ namespace System.Web.UI.HtmlControls{
}
}
- protected new void RenderAttributes(HtmlTextWriter writer){
+ protected override void RenderAttributes(HtmlTextWriter writer){
if (Page != null && Events[EventServerClick] != null){
- WriteOnClickAttribute(
- writer,
- false,
- true,
- CausesValidation == false? Page.Validators.Count > 0: false);
+ /* Got to figure out how to manage events */
}
base.RenderAttributes(writer);
}
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs
index a2e67b44e26..970a48aced9 100644
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlContainerControl.cs
@@ -64,9 +64,7 @@ namespace System.Web.UI.HtmlControls
protected override void Render(HtmlTextWriter writer)
{
- writer.WriteBeginTag (TagName);
- RenderAttributes (writer);
- writer.Write ('>');
+ base.Render (writer);
if (_doChildren)
RenderChildren(writer);
else if (_doText)
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs
index 09e90e20274..aa3f19f2ae3 100644
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlControl.cs
@@ -63,6 +63,13 @@ namespace System.Web.UI.HtmlControls{
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);
@@ -70,38 +77,6 @@ namespace System.Web.UI.HtmlControls{
Attributes.Render(writer);
}
- internal void WriteOnClickAttribute(HtmlTextWriter writer, bool submitsAutomatically, bool submitsProgramatically, bool causesValidation) {
- string local1;
- string local2;
- string local3;
-
- AttributeCollection attr = Attributes;
- local1 = null;
- if (submitsAutomatically) {
- if ((causesValidation))
- local1 = System.Web.UI.Utils.GetClientValidatedEvent(Page);
- }
- else if (submitsProgramatically) {
- if (causesValidation)
- local1 = System.Web.UI.Utils.GetClientValidatedPostBack(this);
- else
- local1 = Page.GetPostBackClientEvent(this, String.Empty);
- }
- if (local1 != null) {
- local2 = attr["language"];
- if (local2 != null)
- attr.Remove("language");
- writer.WriteAttribute("language", "javascript");
- local3 = attr["onclick"];
- if (local3 != null) {
- attr.Remove("onclick");
- writer.WriteAttribute("onclick", local3 + " " + local1);
- return;
- }
- writer.WriteAttribute("onclick", local1);
- }
- }
-
public AttributeCollection Attributes
{
get
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs
index 62135016d4c..a0ca1f13b3b 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlImage.cs
@@ -14,9 +14,9 @@ namespace System.Web.UI.HtmlControls{
public HtmlImage(): base("img"){}
- protected new void RenderAttributes(HtmlTextWriter writer){
+ protected override void RenderAttributes(HtmlTextWriter writer){
PreProcessRelativeReference(writer,"src");
- RenderAttributes(writer);
+ base.RenderAttributes(writer);
writer.Write(" /");
}
@@ -59,6 +59,19 @@ namespace System.Web.UI.HtmlControls{
}
}
+ public int Height
+ {
+ get {
+ string attr = Attributes ["height"];
+ if (attr != null)
+ return Int32.Parse (attr, CultureInfo.InvariantCulture);
+
+ return -1;
+ }
+
+ set { Attributes["height"] = AttributeToString (value); }
+ }
+
public string Src{
get{
string attr = Attributes["src"];
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
index 3f1a75c4133..48be001756c 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs
@@ -23,37 +23,6 @@ namespace System.Web.UI.HtmlControls{
}
}
- protected override void RenderAttributes(HtmlTextWriter writer){
- string attrType = Type;
- bool ofTypeSubmit = (String.Compare(attrType, "submit", true) == 0);
- bool events;
- if (ofTypeSubmit != true){
- events = (Events[EventServerClick] != null);
- }
- else{
- events = false;
- }
- if (Page != null){
- if (ofTypeSubmit != true){
- WriteOnClickAttribute(
- writer,
- false,
- true,
- CausesValidation == false? Page.Validators.Count > 0: false);
- }
- else{
- if (events != true && String.Compare(attrType,"button", true) != 0){
- WriteOnClickAttribute(
- writer,
- false,
- true,
- CausesValidation == false? Page.Validators.Count > 0: false);
- }
- }
- }
- base.RenderAttributes(writer);
- }
-
public void RaisePostBackEvent(string eventArgument){
if(CausesValidation == true){
Page.Validate();
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
index a8a45da640d..1854a3b4dd2 100755
--- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
+++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputImage.cs
@@ -29,18 +29,6 @@ namespace System.Web.UI.HtmlControls{
// if (handler != null) handler.Invoke(this, e);
}
- protected override void RenderAttributes(HtmlTextWriter writer){
- PreProcessRelativeReference(writer,"src");
- if (Page != null && !CausesValidation){
- WriteOnClickAttribute(
- writer,
- false,
- true,
- CausesValidation == false? Page.Validators.Count > 0: false);
- }
- RenderAttributes(writer);
- }
-
public bool LoadPostData(string postDataKey, NameValueCollection postCollection){
string postX = postCollection[String.Concat(RenderedName,".x")];
string postY = postCollection[String.Concat(RenderedName,".y")];
diff --git a/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs b/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs
index 274c1ab5feb..8f4df42b9ef 100755
--- a/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs
+++ b/mcs/class/System.Web/System.Web.UI/AttributeCollection.cs
@@ -13,17 +13,15 @@ namespace System.Web.UI {
public sealed class AttributeCollection
{
- StateBag bag;
- Hashtable list;
+ private StateBag bag;
public AttributeCollection (StateBag bag)
{
this.bag = bag;
- list = new Hashtable ();
}
public int Count {
- get { return list.Count; }
+ get { return bag.Count; }
}
[MonoTODO]
@@ -32,44 +30,43 @@ namespace System.Web.UI {
}
public string this [string key] {
- get { return list [key] as string; }
+ get { return bag [key] as string; }
- set { list [key] = value; }
+ set { bag.Add (key, value); }
}
public ICollection Keys {
- get { return list.Keys; }
+ get { return bag.Keys; }
}
public void Add (string key, string value)
{
- list.Add (key, value);
+ bag.Add (key, value); // if exists, only the value is replaced.
}
public void AddAttributes (HtmlTextWriter writer)
{
- foreach (object key in list.Keys) {
-
- object value = list [key];
- writer.AddAttribute ((string) key, (string) value);
+ foreach (string key in bag.Keys) {
+ string value = bag [key] as string;
+ writer.AddAttribute (key, value);
}
}
public void Clear ()
{
- list.Clear ();
+ bag.Clear ();
}
public void Remove (string key)
{
- list.Remove (key);
+ bag.Remove (key);
}
public void Render (HtmlTextWriter writer)
{
- foreach (object key in list.Keys) {
- object value = list [key];
- writer.WriteAttribute ((string) key, (string) value);
+ foreach (string key in bag.Keys) {
+ string value = bag [key] as string;
+ writer.WriteAttribute (key, value);
}
}
}
diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog
index fb2c6f3c090..3a7953eec6b 100644
--- a/mcs/class/System.Web/System.Web.UI/ChangeLog
+++ b/mcs/class/System.Web/System.Web.UI/ChangeLog
@@ -1,5 +1,14 @@
2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+ * AttributeCollection.cs: don't need a Hastable. StateBag now works
+ fine and takes care of the details.
+
+ * Control.cs: added HasChildren property.
+
+ * StateBag.cs: fixed a couple of nasty bugs.
+
+2002-06-05 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
* Page.cs: run OnInit, OnLoad y PreRender before rendering the page.
Invoke Page_Init and/or Page_Load if the user supplied them (though
this should depend on AutoEventWireUp attribute of Page directive).
diff --git a/mcs/class/System.Web/System.Web.UI/Control.cs b/mcs/class/System.Web/System.Web.UI/Control.cs
index 406cc951a1c..2c8ace32750 100644
--- a/mcs/class/System.Web/System.Web.UI/Control.cs
+++ b/mcs/class/System.Web/System.Web.UI/Control.cs
@@ -439,6 +439,12 @@ namespace System.Web.UI
}
*/
}
+
+ public bool HasChildren
+ {
+ get { return (_controls != null && _controls.Count > 0); }
+ }
+
public event EventHandler DataBinding //DIT
{
add
diff --git a/mcs/class/System.Web/System.Web.UI/StateBag.cs b/mcs/class/System.Web/System.Web.UI/StateBag.cs
index caa45edc69f..44b4a09e060 100644
--- a/mcs/class/System.Web/System.Web.UI/StateBag.cs
+++ b/mcs/class/System.Web/System.Web.UI/StateBag.cs
@@ -54,7 +54,7 @@ namespace System.Web.UI
object val = bag [key];
if (val is StateItem)
- return val;
+ return ((StateItem) val).Value;
return null; //
}
@@ -81,23 +81,17 @@ namespace System.Web.UI
if (key == null || key.Length == 0)
throw new ArgumentException (HttpRuntime.FormatResourceString ("Key_Cannot_Be_Null"));
- StateItem val = null;
-
- if (bag [key] is StateItem)
- val = (StateItem) (bag [key]);
-
+ StateItem val = bag [key] as StateItem; //don't throw exception when null
if(val == null) {
if(value != null || marked) {
val = new StateItem (value);
bag.Add (key, val);
}
-
- } else {
- if (value != null && !marked) {
- bag.Remove (key);
- val.Value = value;
- }
}
+ else if (value == null && !marked)
+ bag.Remove (key);
+ else
+ val.Value = value;
if (val != null && marked)
val.IsDirty = true;