+2005-09-27 Chris Toshok <toshok@ximian.com>
+
+ * Microsoft.Web.UI/ScriptManager.cs: implement things such that
+ things kinda work.
+
+ * Microsoft.Web.UI/Button.cs (AddAttributesToElement): call base
+ class method.
+ (InitializeTypeDescriptor): same.
+ (OnPreRender): same.
+
+ * Microsoft.Web.UI/Label.cs: new implementation.
+
+ * Microsoft.Web.UI/TextBox.cs: new implementation.
+
+ * Microsoft.Web.UI/ListView.cs: new implementation.
+
2005-09-16 Chris Toshok <toshok@ximian.com>
* Test/Microsoft.Web.UI/LabelTest.cs: new test.
protected override void AddAttributesToElement (ScriptTextWriter writer)
{
+ base.AddAttributesToElement (writer);
}
protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
{
+ base.InitializeTypeDescriptor (typeDescriptor);
}
protected override void OnPreRender (EventArgs e)
{
+ base.OnPreRender(e);
}
protected override void Render (HtmlTextWriter writer)
--- /dev/null
+//
+// Microsoft.Web.UI.Label
+//
+// Author:
+// Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+ public class Label : ScriptControl
+ {
+ public Label ()
+ {
+ }
+
+ protected override void AddParsedSubObject (object obj)
+ {
+ base.AddParsedSubObject (obj);
+ }
+
+ protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+ {
+ base.InitializeTypeDescriptor (typeDescriptor);
+
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("text", ScriptType.String, false, "Text"));
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+
+ ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ }
+
+ public override string TagName {
+ get {
+ return "label";
+ }
+ }
+
+ public string Text {
+ get {
+ object o = ViewState["Text"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ if (value == null)
+ ViewState.Remove ("Text");
+ else
+ ViewState["Text"] = value;
+ }
+ }
+ }
+
+}
+
+#endif
--- /dev/null
+//
+// Microsoft.Web.UI.ListView
+//
+// Author:
+// Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+ public class ListView : ScriptControl
+ {
+ ITemplate emptyTemplate;
+ ITemplate layoutTemplate;
+
+ public ListView ()
+ {
+ }
+
+ protected override void AddAttributesToElement (ScriptTextWriter writer)
+ {
+ base.AddAttributesToElement (writer);
+ }
+
+ protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+ {
+ base.InitializeTypeDescriptor (typeDescriptor);
+
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("alternatingItemCssClass", ScriptType.String, false, "AlternatingItemCssClass"));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("data", ScriptType.Object, false, ""));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("length", ScriptType.Number, true, ""));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("layoutTemplate", ScriptType.Object, false, ""));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemCssClass", ScriptType.String, false, "ItemCssClass"));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemTemplateParentElementId", ScriptType.String, false, ""));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("separatorTemplate", ScriptType.Object, false, ""));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("emptyTemplate", ScriptType.Object, false, ""));
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+
+ ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ }
+
+ protected override void RenderScriptTagContents (ScriptTextWriter writer)
+ {
+ base.RenderScriptTagContents (writer);
+
+ writer.WriteStartElement ("layoutTemplate");
+ writer.WriteStartElement ("template");
+ writer.WriteAttributeString ("layoutElement", ID + "_layoutTemplate"); // XXX ?
+ writer.WriteEndElement (); // template
+ writer.WriteEndElement (); // layoutTemplate
+
+ writer.WriteStartElement ("itemTemplate");
+ writer.WriteEndElement (); // itemTemplate
+ }
+
+ public string AlternatingItemCssClass {
+ get {
+ object o = ViewState["AlternatingItemCssClass"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ ViewState["AlternatingItemCssClass"] = value;
+ }
+ }
+
+ public ITemplate EmptyTemplate {
+ get {
+ return emptyTemplate;
+ }
+ set {
+ emptyTemplate = value;
+ }
+ }
+
+ public string ItemCssClass {
+ get {
+ object o = ViewState["ItemCssClass"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ ViewState["ItemCssClass"] = value;
+ }
+ }
+
+ public string ItemTemplateControlID {
+ get {
+ object o = ViewState["ItemTemplateControlID"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ ViewState["ItemTemplateControlID"] = value;
+ }
+ }
+
+ public ITemplate LayoutTemplate {
+ get {
+ return layoutTemplate;
+ }
+ set {
+ layoutTemplate = value;
+ }
+ }
+
+ public string SeparatorTemplateControlID {
+ get {
+ object o = ViewState["SeparatorTemplateControlID"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ ViewState["SeparatorTemplateControlID"] = value;
+ }
+ }
+
+ public override string TagName {
+ get {
+ return "listView";
+ }
+ }
+ }
+
+}
+
+#endif
#if NET_2_0
using System;
+using System.Collections;
+using System.Collections.Generic;
using System.Web.UI;
namespace Microsoft.Web.UI
{
- public class ScriptManager : Control
+ class ScriptReference
{
+ public string scriptPath;
+ public bool commonScript;
+ }
+
+ class ScriptNamespace
+ {
+ public string prefix;
+ public string namespaceUri;
+ }
+
+ internal class XmlScriptNode : Control
+ {
+ ScriptManager mgr;
+
+ public XmlScriptNode (ScriptManager mgr)
+ {
+ this.mgr = mgr;
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ ScriptTextWriter scriptwriter = new ScriptTextWriter (writer);
+
+ scriptwriter.WriteStartElement ("script");
+ scriptwriter.WriteAttributeString ("type", "text/xml-script");
+ scriptwriter.WriteStartElement ("page");
+ scriptwriter.WriteAttributeString ("xmlns:script", "http://schemas.microsoft.com/xml-script/2005");
+
+ scriptwriter.WriteStartElement ("components");
+ foreach (IScriptComponent component in mgr.Components) {
+ if (((IScriptObject)component).Owner == null) // only render the toplevel script objects
+ component.RenderScript (scriptwriter);
+ }
+ scriptwriter.WriteEndElement (); // components
+
+ scriptwriter.WriteStartElement ("references");
+ foreach (string scriptPath in mgr.ScriptRefs.Keys) {
+ if ((bool)mgr.ScriptRefs[scriptPath]) {
+ scriptwriter.WriteStartElement ("add");
+ scriptwriter.WriteAttributeString ("src", scriptPath);
+ scriptwriter.WriteEndElement ();
+ }
+ }
+ scriptwriter.WriteEndElement (); //references
+
+ scriptwriter.WriteEndElement (); // page
+ scriptwriter.WriteEndElement (); // script
+
+ ScriptManager.Pages.Remove (Page);
+ }
+ }
+
+ public class ScriptManager : Control, INamingContainer, IScriptComponentContainer
+ {
+ internal ScriptComponentCollection Components;
+ internal Hashtable ScriptRefs;
+ internal List<ScriptNamespace> Namespaces;
+
+ internal static Hashtable Pages = new Hashtable();
+
public ScriptManager ()
{
- throw new NotImplementedException ();
+ Components = new ScriptComponentCollection();
+ Namespaces = new List<ScriptNamespace>();
+ ScriptRefs = new Hashtable();
+ }
+
+ protected override void OnInit (EventArgs e)
+ {
+ base.OnInit(e);
+
+ if (Page != null) {
+ Pages.Add (Page, this);
+ Page.Controls.Add (new XmlScriptNode(this));
+ }
}
public static ScriptManager GetCurrentScriptManager (Page page)
{
- throw new NotImplementedException ();
+ return (ScriptManager)Pages[page];
}
public void RegisterComponent (IScriptComponent component)
{
- throw new NotImplementedException ();
+ Components.Add (component);
}
public void RegisterScriptNamespace (string prefix, string namespaceUri)
{
- throw new NotImplementedException ();
+ ScriptNamespace ns = new ScriptNamespace ();
+ ns.prefix = prefix;
+ ns.namespaceUri = namespaceUri;
+ Namespaces.Add (ns);
}
public void RegisterScriptReference (string scriptPath, bool commonScript)
{
- throw new NotImplementedException ();
+ if (ScriptRefs.Contains (scriptPath))
+ return;
+
+ ScriptRefs.Add (scriptPath, commonScript);
}
public void RegisterScriptReference (string scriptPath)
{
- throw new NotImplementedException ();
+ RegisterScriptReference (scriptPath, false);
}
}
}
--- /dev/null
+//
+// Microsoft.Web.UI.TextBox
+//
+// Author:
+// Chris Toshok (toshok@ximian.com)
+//
+//
+// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#if NET_2_0
+
+using System;
+using System.ComponentModel;
+using System.Web.UI;
+using Microsoft.Web;
+
+namespace Microsoft.Web.UI
+{
+ public class TextBox : ScriptControl
+ {
+ public TextBox ()
+ {
+ }
+
+ protected override void AddAttributesToElement (ScriptTextWriter writer)
+ {
+ base.AddAttributesToElement (writer);
+ }
+
+ protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
+ {
+ base.InitializeTypeDescriptor (typeDescriptor);
+
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("validators", ScriptType.Array, true, "Validators"));
+ typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("text", ScriptType.String, false, "Text"));
+ }
+
+ protected override void OnPreRender (EventArgs e)
+ {
+ base.OnPreRender (e);
+
+ ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
+ mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
+ }
+
+ protected override void Render (HtmlTextWriter writer)
+ {
+ }
+
+ protected override void RenderScriptTagContents (ScriptTextWriter writer)
+ {
+ base.RenderScriptTagContents (writer);
+
+ if (AutoCompletionServiceMethod != ""
+ && AutoCompletionServiceUrl != "") {
+ writer.WriteStartElement ("behaviors");
+ writer.WriteStartElement ("autoComplete");
+ writer.WriteAttributeString ("serviceURL", AutoCompletionServiceUrl);
+ writer.WriteAttributeString ("serviceMethod", AutoCompletionServiceMethod);
+ if (AutoCompletionMinimumPrefixLength != 0)
+ writer.WriteAttributeString ("minimumPrefixLength", AutoCompletionMinimumPrefixLength.ToString());
+
+ writer.WriteAttributeString ("completionList", ID + "__autocomplete"); // XXX ?
+
+ writer.WriteEndElement (); // autoComplete
+ writer.WriteEndElement (); // behaviors
+ }
+
+ }
+
+ public int AutoCompletionInterval {
+ get {
+ object o = ViewState["AutoCompletionInterval"];
+ if (o == null)
+ return 1000;
+ return (int)o;
+ }
+ set {
+ ViewState["AutoCompletionInterval"] = value;
+ }
+ }
+
+ [MonoTODO]
+ public int AutoCompletionMinimumPrefixLength {
+ get {
+ object o = ViewState["AutoCompletionMinimumPrefixLength"];
+ if (o == null)
+ return 3;
+ return (int)o;
+ }
+ set {
+ ViewState["AutoCompletionMinimumPrefixLength"] = value;
+ }
+ }
+
+ public string AutoCompletionServiceMethod {
+ get {
+ return (string)ViewState["AutoCompletionServiceMethod"];
+ }
+ set {
+ ViewState["AutoCompletionServiceMethod"] = value;
+ }
+ }
+
+ public string AutoCompletionServiceUrl {
+ get {
+ return (string)ViewState["AutoCompletionServiceUrl"];
+ }
+ set {
+ ViewState["AutoCompletionServiceUrl"] = value;
+ }
+ }
+
+ public int AutoCompletionSetCount {
+ get {
+ object o = ViewState["AutoCompletionSetCount"];
+ if (o == null)
+ return 10;
+ return (int)o;
+ }
+ set {
+ ViewState["AutoCompletionSetCount"] = value;
+ }
+ }
+
+ public int Size {
+ get {
+ object o = ViewState["Size"];
+ if (o == null)
+ return 0;
+ return (int)o;
+ }
+ set {
+ ViewState["Size"] = value;
+ }
+ }
+
+ public override string TagName {
+ get {
+ return "textBox";
+ }
+ }
+
+ public string Text {
+ get {
+ object o = ViewState["Text"];
+ if (o == null)
+ return "";
+ return (string)o;
+ }
+ set {
+ ViewState["Text"] = value;
+ }
+ }
+ }
+
+}
+
+#endif