2 // Microsoft.Web.UI.ListView
5 // Chris Toshok (toshok@ximian.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.ComponentModel;
37 namespace Microsoft.Web.UI
39 public class ListView : ScriptControl
41 ITemplate emptyTemplate;
42 ITemplate layoutTemplate;
48 protected override void AddAttributesToElement (ScriptTextWriter writer)
50 base.AddAttributesToElement (writer);
53 protected override void InitializeTypeDescriptor (ScriptTypeDescriptor typeDescriptor)
55 base.InitializeTypeDescriptor (typeDescriptor);
57 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("alternatingItemCssClass", ScriptType.String, false, "AlternatingItemCssClass"));
58 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("data", ScriptType.Object, false, ""));
59 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("length", ScriptType.Number, true, ""));
60 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("layoutTemplate", ScriptType.Object, false, ""));
61 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemCssClass", ScriptType.String, false, "ItemCssClass"));
62 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("itemTemplateParentElementId", ScriptType.String, false, ""));
63 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("separatorTemplate", ScriptType.Object, false, ""));
64 typeDescriptor.AddProperty (new ScriptPropertyDescriptor ("emptyTemplate", ScriptType.Object, false, ""));
67 protected override void OnPreRender (EventArgs e)
71 ScriptManager mgr = ScriptManager.GetCurrentScriptManager (Page);
72 mgr.RegisterScriptReference ("ScriptLibrary/AtlasUI.js", true);
73 mgr.RegisterScriptReference ("ScriptLibrary/AtlasControls.js", true);
76 protected override void Render (HtmlTextWriter writer)
80 protected override void RenderScriptTagContents (ScriptTextWriter writer)
82 base.RenderScriptTagContents (writer);
84 writer.WriteStartElement ("layoutTemplate");
85 writer.WriteStartElement ("template");
86 writer.WriteAttributeString ("layoutElement", ID + "_layoutTemplate"); // XXX ?
87 writer.WriteEndElement (); // template
88 writer.WriteEndElement (); // layoutTemplate
90 writer.WriteStartElement ("itemTemplate");
91 writer.WriteEndElement (); // itemTemplate
94 public string AlternatingItemCssClass {
96 object o = ViewState["AlternatingItemCssClass"];
102 ViewState["AlternatingItemCssClass"] = value;
106 public ITemplate EmptyTemplate {
108 return emptyTemplate;
111 emptyTemplate = value;
115 public string ItemCssClass {
117 object o = ViewState["ItemCssClass"];
123 ViewState["ItemCssClass"] = value;
127 public string ItemTemplateControlID {
129 object o = ViewState["ItemTemplateControlID"];
135 ViewState["ItemTemplateControlID"] = value;
139 public ITemplate LayoutTemplate {
141 return layoutTemplate;
144 layoutTemplate = value;
148 public string SeparatorTemplateControlID {
150 object o = ViewState["SeparatorTemplateControlID"];
156 ViewState["SeparatorTemplateControlID"] = value;
160 public override string TagName {