2 // FieldTemplateUserControl.cs
5 // Atsushi Enomoto <atsushi@ximian.com>
6 // Marek Habersack <mhabersack@novell.com>
8 // Copyright (C) 2008-2009 Novell Inc. http://novell.com
12 // Permission is hereby granted, free of charge, to any person obtaining
13 // a copy of this software and associated documentation files (the
14 // "Software"), to deal in the Software without restriction, including
15 // without limitation the rights to use, copy, modify, merge, publish,
16 // distribute, sublicense, and/or sell copies of the Software, and to
17 // permit persons to whom the Software is furnished to do so, subject to
18 // the following conditions:
20 // The above copyright notice and this permission notice shall be
21 // included in all copies or substantial portions of the Software.
23 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32 using System.Collections;
33 using System.Collections.Generic;
34 using System.Collections.Specialized;
35 using System.Globalization;
36 using System.Security.Permissions;
37 using System.Security.Principal;
38 using System.Web.Caching;
40 using System.Web.UI.WebControls;
42 namespace System.Web.DynamicData
44 [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
45 [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
46 public class FieldTemplateUserControl : UserControl, IBindableControl, IFieldTemplate
48 public MetaChildrenColumn ChildrenColumn {
50 MetaColumn column = Column;
51 var ret = column as MetaChildrenColumn;
53 string name = column == null ? null : column.Name;
54 throw new Exception ("'" + name + "' is not a children column and cannot be used here.");
62 protected string ChildrenPath {
63 get { return ChildrenColumn.GetChildrenListPath (Row); }
67 public MetaColumn Column {
69 IFieldTemplateHost host = Host;
78 public virtual Control DataControl { get; private set; }
80 public virtual object FieldValue { get; set; }
82 public virtual string FieldValueEditString { get; private set; }
84 public virtual string FieldValueString { get; private set; }
87 public MetaForeignKeyColumn ForeignKeyColumn {
89 MetaColumn column = Column;
90 var ret = column as MetaForeignKeyColumn;
92 string name = column == null ? null : column.Name;
93 throw new Exception ("'" + name + "' is not a foreign key column and cannot be used here.");
101 protected string ForeignKeyPath {
102 get { return ForeignKeyColumn.GetForeignKeyDetailsPath (Row); }
106 public IFieldFormattingOptions FormattingOptions { get; private set; }
108 public IFieldTemplateHost Host { get; private set; }
111 public System.ComponentModel.AttributeCollection MetadataAttributes {
113 MetaColumn column = Column;
117 return column.Attributes;
122 public DataBoundControlMode Mode {
124 IFieldTemplateHost host = Host;
125 return host == null ? DataBoundControlMode.ReadOnly : host.Mode;
130 public virtual object Row {
133 return page == null ? null : page.GetDataItem ();
138 public MetaTable Table {
140 MetaColumn column = Column;
141 return column == null ? null : column.Table;
146 protected string BuildChildrenPath (string path)
148 throw new NotImplementedException ();
152 protected string BuildForeignKeyPath (string path)
154 throw new NotImplementedException ();
158 protected virtual object ConvertEditedValue (string value)
160 throw new NotImplementedException ();
164 protected virtual void ExtractForeignKey (IDictionary dictionary, string selectedValue)
166 throw new NotImplementedException ();
170 protected virtual void ExtractValues (IOrderedDictionary dictionary)
172 throw new NotImplementedException ();
176 protected FieldTemplateUserControl FindOtherFieldTemplate (string columnName)
178 throw new NotImplementedException ();
182 public virtual string FormatFieldValue (object fieldValue)
184 throw new NotImplementedException ();
188 protected virtual object GetColumnValue (MetaColumn column)
190 throw new NotImplementedException ();
194 void IBindableControl.ExtractValues (IOrderedDictionary dictionary)
196 ExtractValues (dictionary);
199 void IFieldTemplate.SetHost (IFieldTemplateHost host)
205 protected void IgnoreModelValidationAttribute (Type attributeType)
207 throw new NotImplementedException ();
211 protected void PopulateListControl (ListControl listControl)
213 throw new NotImplementedException ();
217 protected virtual void SetUpValidator (BaseValidator validator)
222 protected virtual void SetUpValidator (BaseValidator validator, MetaColumn column)
224 throw new NotImplementedException ();