diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-01-17 20:17:41 +0300 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2003-01-17 20:17:41 +0300 |
commit | 6c3561438526d768ebc614bbb719127e1b3fb0d8 (patch) | |
tree | a4384f4a5decd035908e4ff356795ccf3c936303 /mcs/class | |
parent | 3a1f65554614a9dd6e05bd66b9bb157610d78be7 (diff) |
2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* System.Web/HttpRequest.cs: implemented CurrentExecutionFilePath.
* System.Web.UI/Control.cs: some more tweaks to naming containers stuff.
* System.Web.UI/DataBinder.cs: don't throw exception if the container
is null.
* System.Web.UI/Page.cs: now we can render client scripts, startup
scripts and hidden fields. Only render __VIEWSTATE if there is someone
that will take care of it.
(RaisePostBackEvents): first try the last one that required raise event,
then try __EVENTTARGET.
* System.Web.UI.HtmlControls/HtmlForm.cs: render 'action' attribute.
* System.Web.UI.WebControls/BaseDataList.cs: what can I say for this
one? I spent so many time until I finally found this that I'm gonna
miss this f....g bug... ;-). Farewell. Now we can get events from
image buttons inside Data*.
* System.Web.UI.WebControls/DataList.cs: now the value stored in
ViewState for item count is correct.
svn path=/trunk/mcs/; revision=10627
Diffstat (limited to 'mcs/class')
11 files changed, 146 insertions, 70 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog index 00a508e63fc..0c3d8e41974 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog @@ -1,3 +1,7 @@ +2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * System.Web.UI.HtmlControls/HtmlForm.cs: render 'action' attribute. + 2003-01-03 Gonzalo Paniagua Javier <gonzalo@ximian.com> * HtmlInputButton.cs: fixed bug #35677. 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 da513f73035..4f0b4f1f33e 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlForm.cs @@ -21,8 +21,8 @@ namespace System.Web.UI.HtmlControls{ Attributes.Remove("name");
writer.WriteAttribute("method", Method);
Attributes.Remove("method");
- //writer.WriteAttribute("action", Action, true);
- //Attributes.Remove("action");
+ writer.WriteAttribute("action", Action, true);
+ Attributes.Remove("action");
if (Enctype != null){
writer.WriteAttribute ("enctype", Enctype);
Attributes.Remove ("enctype");
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs index a2ae6a1d7be..aabd78d585e 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/BaseDataList.cs @@ -240,7 +240,7 @@ namespace System.Web.UI.WebControls Controls.Clear();
if(ViewState[ItemCountViewStateKey]!=null)
{
- CreateControlHierarchy(true);
+ CreateControlHierarchy(false);
ClearChildViewState();
}
}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 6941c1e7542..51dc36cedf5 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,3 +1,12 @@ +2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * BaseDataList.cs: what can I say for this one? I spent so many time + until I finally found this that I'm gonna miss this f....g bug... ;-). + Farewell. Now we can get events from image buttons inside Data*. + + * DataList.cs: now the value stored in ViewState for item count is + correct. + 2003-01-08 Gonzalo Paniagua Javier <gonzalo@ximian.com> * DataGrid.cs: default value for ShowHeaders is true. Fixed style for diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs index 2a69a90f782..3e78627f0c4 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataList.cs @@ -628,13 +628,12 @@ namespace System.Web.UI.WebControls } else { dkeys.Clear (); source = DataSourceHelper.GetResolvedDataSource (DataSource, DataMember); - if (source != null && source is ICollection) { + if (source is ICollection) { dkeys.Capacity = ((ICollection) source).Count; itemsArray.Capacity = ((ICollection) source).Count; } } - IEnumerator listEnumerator = null; int itemCount = 0; if (source != null) { int index = 0; @@ -646,9 +645,8 @@ namespace System.Web.UI.WebControls CreateItem (-1, ListItemType.Header, useDataSource, null); foreach (object current in source) { - if (!useDataSource) { + if (!useDataSource) dkeys.Add (DataBinder.GetPropertyValue (current, dataKey)); - } ListItemType type = ListItemType.Item; if (index == editIndex) { @@ -670,9 +668,8 @@ namespace System.Web.UI.WebControls CreateItem (-1, ListItemType.Footer, useDataSource, null); } - if (useDataSource) { - ViewState ["_!ItemCount"] = (listEnumerator != null ? itemCount : -1); - } + if (useDataSource) + ViewState ["_!ItemCount"] = (source != null ? itemCount : -1); } /// <summary> diff --git a/mcs/class/System.Web/System.Web.UI/ChangeLog b/mcs/class/System.Web/System.Web.UI/ChangeLog index 6c043fa4b60..564d1459118 100644 --- a/mcs/class/System.Web/System.Web.UI/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI/ChangeLog @@ -1,3 +1,14 @@ +2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * Control.cs: some more tweaks to naming containers stuff. + * DataBinder.cs: don't throw exception if the container is null. + + * Page.cs: now we can render client scripts, startup scripts and hidden + fields. Only render __VIEWSTATE if there is someone that will take care + of it. + (RaisePostBackEvents): first try the last one that required raise event, + then try __EVENTTARGET. + 2003-01-16 Gonzalo Paniagua Javier <gonzalo@ximian.com> * Control.cs: fixes in UniqueID, FindControl, AddedControl, diff --git a/mcs/class/System.Web/System.Web.UI/Control.cs b/mcs/class/System.Web/System.Web.UI/Control.cs index 1b06074e5ae..9e2720bab14 100644 --- a/mcs/class/System.Web/System.Web.UI/Control.cs +++ b/mcs/class/System.Web/System.Web.UI/Control.cs @@ -244,7 +244,7 @@ namespace System.Web.UI }
if (_userId == null)
- _userId = "_uniqueIDctrl" + _namingContainer.defaultNumberID++;
+ _userId = _namingContainer.GetDefaultName ();
string prefix = _namingContainer.UniqueID;
if (_namingContainer == _page || prefix == null) {
@@ -363,6 +363,11 @@ namespace System.Web.UI defaultNumberID = 0;
}
+ string GetDefaultName ()
+ {
+ return "_ctrl" + defaultNumberID++;
+ }
+
void NullifyUniqueID ()
{
uniqueID = null;
@@ -385,7 +390,7 @@ namespace System.Web.UI if (_isNamingContainer) {
control._namingContainer = this;
if (control.AutoID == true && control._userId == null) {
- control._userId = "_ictrl" + defaultNumberID++;
+ control._userId = GetDefaultName ();
}
}
@@ -479,7 +484,7 @@ namespace System.Web.UI string idfound = id.Substring (pathOffset, colon - pathOffset);
namingContainer = LookForControlByName (idfound);
- if (namingContainer == null || !namingContainer._isNamingContainer)
+ if (namingContainer == null)
return null;
return namingContainer.FindControl (id, colon + 1);
@@ -747,7 +752,7 @@ namespace System.Web.UI if (namingContainer != null &&
namingContainer._userId == null &&
namingContainer.autoID)
- namingContainer._userId = "_ictrl" + namingContainer.defaultNumberID++;
+ namingContainer._userId = namingContainer.GetDefaultName ();
foreach (Control c in _controls) {
c._page = Page;
diff --git a/mcs/class/System.Web/System.Web.UI/DataBinder.cs b/mcs/class/System.Web/System.Web.UI/DataBinder.cs index d5524b1daac..5ab388c6d89 100755 --- a/mcs/class/System.Web/System.Web.UI/DataBinder.cs +++ b/mcs/class/System.Web/System.Web.UI/DataBinder.cs @@ -33,15 +33,12 @@ namespace System.Web.UI { public static object Eval (object container, string expression) { - if (container == null) - throw new ArgumentNullException ("container"); - if (expression == null) throw new ArgumentNullException ("expression"); object current = container; - while (true) { + while (current != null) { int dot = expression.IndexOf ('.'); int size = (dot == -1) ? expression.Length : dot; string prop = expression.Substring (0, size); @@ -67,9 +64,6 @@ namespace System.Web.UI { public static object GetIndexedPropertyValue (object container, string expr) { - if (container == null) - throw new ArgumentNullException ("container"); - if (expr == null) throw new ArgumentNullException ("expr"); @@ -109,6 +103,9 @@ namespace System.Web.UI { container = GetPropertyValue (container, property); } + if (container == null) + return null; + Type t = container.GetType (); // MS does not seem to look for any other than "Item"!!! object [] atts = t.GetCustomAttributes (typeof (DefaultMemberAttribute), false); @@ -139,8 +136,8 @@ namespace System.Web.UI { public static object GetPropertyValue (object container, string propName) { - if (container == null || propName == null) - throw new ArgumentException (); + if (propName == null) + throw new ArgumentNullException ("propName"); PropertyDescriptor prop = TypeDescriptor.GetProperties (container).Find (propName, true); if (prop == null) { diff --git a/mcs/class/System.Web/System.Web.UI/Page.cs b/mcs/class/System.Web/System.Web.UI/Page.cs index 0458adad43a..af39217060c 100755 --- a/mcs/class/System.Web/System.Web.UI/Page.cs +++ b/mcs/class/System.Web/System.Web.UI/Page.cs @@ -42,15 +42,17 @@ public class Page : TemplateControl, IHttpHandler private object _savedViewState; private ArrayList _requiresPostBack; private ArrayList requiresPostDataChanged; - private ArrayList requiresRaiseEvent; + private IPostBackEventHandler requiresRaiseEvent; private NameValueCollection secondPostData; private bool requiresPostBackScript = false; private bool postBackScriptRendered = false; + Hashtable clientScriptBlocks; + Hashtable startupScriptBlocks; + Hashtable hiddenFields; + bool handleViewState; - #region Fields - protected const string postEventArgumentID = ""; //FIXME - protected const string postEventSourceID = ""; - #endregion + protected const string postEventArgumentID = "__EVENTARGUMENT"; + protected const string postEventSourceID = "__EVENTTARGET"; #region Constructor public Page () @@ -150,10 +152,8 @@ public class Page : TemplateControl, IHttpHandler } } - [MonoTODO] - public bool IsReusable - { - get { throw new NotImplementedException (); } + public bool IsReusable { + get { return false; } } public bool IsValid @@ -323,7 +323,7 @@ public class Page : TemplateControl, IHttpHandler public virtual int GetTypeHashCode () { - return GetHashCode (); + return 0; } [MonoTODO] @@ -336,16 +336,20 @@ public class Page : TemplateControl, IHttpHandler throw new NotImplementedException (); } - [MonoTODO] public bool IsClientScriptBlockRegistered (string key) { - throw new NotImplementedException (); + if (clientScriptBlocks == null) + return false; + + return clientScriptBlocks.ContainsKey (key); } - [MonoTODO] public bool IsStartupScriptRegistered (string key) { - throw new NotImplementedException (); + if (startupScriptBlocks == null) + return false; + + return startupScriptBlocks.ContainsKey (key); } public string MapPath (string virtualPath) @@ -355,21 +359,43 @@ public class Page : TemplateControl, IHttpHandler private void RenderPostBackScript (HtmlTextWriter writer, string formUniqueID) { - writer.WriteLine ("<input type=\"hidden\" name=\"__EVENTTARGET\" value=\"\" />"); - writer.WriteLine ("<input type=\"hidden\" name=\"__EVENTARGUMENT\" value=\"\" />"); + writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventSourceID); + writer.WriteLine ("<input type=\"hidden\" name=\"{0}\" value=\"\" />", postEventArgumentID); writer.WriteLine (); writer.WriteLine ("<script language=\"javascript\">"); writer.WriteLine ("<!--"); writer.WriteLine ("\tfunction __doPostBack(eventTarget, eventArgument) {"); writer.WriteLine ("\t\tvar theform = document.{0};", formUniqueID); - writer.WriteLine ("\t\ttheform.__EVENTTARGET.value = eventTarget;"); - writer.WriteLine ("\t\ttheform.__EVENTARGUMENT.value = eventArgument;"); + writer.WriteLine ("\t\ttheform.{0}.value = eventTarget;", postEventSourceID); + writer.WriteLine ("\t\ttheform.{0}.value = eventArgument;", postEventArgumentID); writer.WriteLine ("\t\ttheform.submit();"); writer.WriteLine ("\t}"); writer.WriteLine ("// -->"); writer.WriteLine ("</script>"); } + static void WriteScripts (HtmlTextWriter writer, Hashtable scripts) + { + if (scripts == null) + return; + + foreach (string key in scripts.Values) + writer.WriteLine (key); + } + + void WriteHiddenFields (HtmlTextWriter writer) + { + if (hiddenFields == null) + return; + + foreach (string key in hiddenFields.Keys) { + string value = hiddenFields [key] as string; + writer.WriteLine ("\n<input type=\"hidden\" name=\"{0}\" value=\"{1}\" />", key, value); + } + + hiddenFields = null; + } + internal void OnFormRender (HtmlTextWriter writer, string formUniqueID) { if (renderingForm) @@ -377,12 +403,18 @@ public class Page : TemplateControl, IHttpHandler renderingForm = true; writer.WriteLine (); - writer.Write ("<input type=\"hidden\" name=\"__VIEWSTATE\" "); - writer.WriteLine ("value=\"{0}\" />", GetViewStateString ()); + WriteHiddenFields (writer); if (requiresPostBackScript) { RenderPostBackScript (writer, formUniqueID); postBackScriptRendered = true; } + + if (handleViewState) { + writer.Write ("<input type=\"hidden\" name=\"__VIEWSTATE\" "); + writer.WriteLine ("value=\"{0}\" />", GetViewStateString ()); + } + + WriteScripts (writer, clientScriptBlocks); } internal string GetViewStateString () @@ -398,6 +430,8 @@ public class Page : TemplateControl, IHttpHandler if (!postBackScriptRendered && requiresPostBackScript) RenderPostBackScript (writer, formUniqueID); + WriteHiddenFields (writer); + WriteScripts (writer, startupScriptBlocks); renderingForm = false; postBackScriptRendered = false; } @@ -409,7 +443,7 @@ public class Page : TemplateControl, IHttpHandler Hashtable used = new Hashtable (); foreach (string id in data.AllKeys){ - if (id == "__VIEWSTATE" || id == "__EVENTTARGET" || id == "__EVENTARGUMENT") + if (id == "__VIEWSTATE" || id == postEventSourceID || id == postEventArgumentID) continue; string real_id = id; @@ -477,8 +511,6 @@ public class Page : TemplateControl, IHttpHandler WebTrace.WriteLine ("SavePageViewState"); SavePageViewState (); //-- - StringBuilder sb = new StringBuilder (); - StringWriter sr = new StringWriter (sb); HtmlTextWriter output = new HtmlTextWriter (context.Response.Output); WebTrace.WriteLine ("RenderControl"); RenderControl (output); @@ -491,26 +523,25 @@ public class Page : TemplateControl, IHttpHandler internal void RaisePostBackEvents () { + if (requiresRaiseEvent != null) { + RaisePostBackEvent (requiresRaiseEvent, null); + return; + } + NameValueCollection postdata = DeterminePostBackMode (); if (postdata == null) return; - string eventTarget = postdata ["__EVENTTARGET"]; - if (eventTarget != null && eventTarget.Length > 0) { - Control target = FindControl (eventTarget); - if (!(target is IPostBackEventHandler)) - return; - string eventArgument = postdata ["__EVENTARGUMENT"]; - RaisePostBackEvent ((IPostBackEventHandler) target, eventArgument); + string eventTarget = postdata [postEventSourceID]; + if (eventTarget == null || eventTarget.Length == 0) return; - } - if (requiresRaiseEvent == null) + IPostBackEventHandler target = FindControl (eventTarget) as IPostBackEventHandler; + if (target == null) return; - foreach (Control c in requiresRaiseEvent) - RaisePostBackEvent ((IPostBackEventHandler) c, postdata [c.ID]); - requiresRaiseEvent.Clear (); + string eventArgument = postdata [postEventArgumentID]; + RaisePostBackEvent (target, eventArgument); } internal void RaiseChangedEvents () @@ -520,6 +551,7 @@ public class Page : TemplateControl, IHttpHandler foreach (IPostBackDataHandler ipdh in requiresPostDataChanged) ipdh.RaisePostDataChangedEvent (); + requiresPostDataChanged.Clear (); } @@ -534,19 +566,27 @@ public class Page : TemplateControl, IHttpHandler throw new NotImplementedException (); } - [MonoTODO] public virtual void RegisterClientScriptBlock (string key, string script) { - throw new NotImplementedException (); + if (IsClientScriptBlockRegistered (key)) + return; + + if (clientScriptBlocks == null) + clientScriptBlocks = new Hashtable (); + + clientScriptBlocks.Add (key, script); } - [MonoTODO] public virtual void RegisterHiddenField (string hiddenFieldName, string hiddenFieldInitialValue) { - throw new NotImplementedException (); + if (hiddenFields == null) + hiddenFields = new Hashtable (); + + if (!hiddenFields.ContainsKey (hiddenFieldName)) + hiddenFields.Add (hiddenFieldName, hiddenFieldInitialValue); } - [MonoTODO] + [MonoTODO] public void RegisterClientScriptFile (string a, string b, string c) { throw new NotImplementedException (); @@ -568,16 +608,23 @@ public class Page : TemplateControl, IHttpHandler public virtual void RegisterRequiresRaiseEvent (IPostBackEventHandler control) { - if (requiresRaiseEvent == null) - requiresRaiseEvent = new ArrayList (); + requiresRaiseEvent = control; + } - requiresRaiseEvent.Add (control); + public virtual void RegisterStartupScript (string key, string script) + { + if (IsStartupScriptRegistered (key)) + return; + + if (startupScriptBlocks == null) + startupScriptBlocks = new Hashtable (); + + startupScriptBlocks.Add (key, script); } - [MonoTODO] public void RegisterViewStateHandler () { - // Do nothing + handleViewState = true; } protected virtual void SavePageStateToPersistenceMedium (object viewState) @@ -619,6 +666,9 @@ public class Page : TemplateControl, IHttpHandler internal void SavePageViewState () { + if (!handleViewState) + return; + Pair pair = new Pair (); pair.First = SaveViewStateRecursive (); if (_requiresPostBack != null && _requiresPostBack.Count > 0) diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index b0921719f50..ba33cb3caf9 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,7 @@ +2003-01-17 Gonzalo Paniagua Javier <gonzalo@ximian.com> + + * HttpRequest.cs: implemented CurrentExecutionFilePath. + 2003-01-10 Gonzalo Paniagua Javier <gonzalo@ximian.com> * HttpApplication.cs: keep _lasterror if no context. Attach diff --git a/mcs/class/System.Web/System.Web/HttpRequest.cs b/mcs/class/System.Web/System.Web/HttpRequest.cs index 41be1619f48..99105ce5b2f 100644 --- a/mcs/class/System.Web/System.Web/HttpRequest.cs +++ b/mcs/class/System.Web/System.Web/HttpRequest.cs @@ -492,10 +492,9 @@ namespace System.Web { }
}
- [MonoTODO()]
public string CurrentExecutionFilePath {
get {
- throw new NotImplementedException();
+ return FilePath;
}
}
|