5 // Atsushi Enomoto <atsushi@ximian.com>
7 // Copyright (C) 2008 Novell Inc. http://novell.com
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.Collections;
32 using System.Collections.Generic;
33 using System.Collections.Specialized;
34 using System.ComponentModel;
36 using System.Globalization;
37 using System.Security.Permissions;
38 using System.Security.Principal;
39 using System.Web.Caching;
41 using System.Web.UI.WebControls;
42 using System.Web.DynamicData.ModelProviders;
44 namespace System.Web.DynamicData
46 [ToolboxBitmap (typeof(DynamicControl), "DynamicControl.ico")]
47 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
48 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
49 public class DynamicControl : Control, IAttributeAccessor, IFieldTemplateHost, IFieldFormattingOptions
51 Dictionary <string, string> attributes;
53 public DynamicControl ()
58 public DynamicControl (DataBoundControlMode mode)
60 throw new NotImplementedException ();
64 [Category ("Behavior")]
65 [DefaultValue (false)]
66 public bool ApplyFormatInEditMode { get; set; }
70 public MetaColumn Column { get; set; }
73 [Category ("Behavior")]
74 [DefaultValue (false)]
75 public bool ConvertEmptyStringToNull { get; set; }
78 [Category ("Appearance")]
81 public virtual string CssClass { get; set; }
86 public string DataField { get; set; }
91 public string DataFormatString { get; set; }
95 public Control FieldTemplate { get; private set; }
98 [Category ("Behavior")]
100 public bool HtmlEncode { get; set; }
103 IFieldFormattingOptions IFieldTemplateHost.FormattingOptions {
104 get { throw new NotImplementedException (); }
108 public DataBoundControlMode Mode { get; set; }
111 [Category ("Behavior")]
113 public string NullDisplayText { get; set; }
117 public virtual MetaTable Table { get; private set; }
120 [Category ("Behavior")]
122 public virtual string UIHint { get; set; }
126 [Category ("Behavior")]
128 public virtual string ValidationGroup { get; set; }
130 public string GetAttribute (string key)
132 if (attributes == null)
136 if (attributes.TryGetValue (key, out ret))
143 protected override void OnInit (EventArgs e)
148 protected override void Render (HtmlTextWriter writer)
150 base.Render (writer);
154 internal void InternalSetAttributes (Dictionary <string, string> attributes)
156 this.attributes = attributes;
159 public void SetAttribute (string key, string value)
161 if (attributes == null)
162 attributes = new Dictionary <string, string> ();
164 if (attributes.ContainsKey (key))
165 attributes [key] = value;
167 attributes.Add (key, value);