-//\r
-// System.Web.UI.HtmlControls.HtmlControl.cs\r
-//\r
-// Author\r
-// Bob Smith <bob@thestuff.net>\r
-//\r
-//\r
-// (C) Bob Smith\r
-//\r
-\r
-using System;\r
-using System.ComponentModel;\r
-using System.ComponentModel.Design;\r
-using System.Globalization;\r
-using System.Web;\r
-using System.Web.UI;\r
-\r
-namespace System.Web.UI.HtmlControls{\r
- \r
- [ToolboxItem(false)]\r
- [Designer ("System.Web.UI.Design.HtmlIntrinsicControlDesigner, " + Consts.AssemblySystem_Design,\r
- "System.ComponentModel.Design.IDesigner")]\r
- public abstract class HtmlControl : Control, IAttributeAccessor\r
- {\r
- internal string _tagName;\r
- private AttributeCollection _attributes;\r
-\r
- \r
-#if NET_2_0\r
- protected\r
-#else\r
- public\r
-#endif\r
- HtmlControl() : this ("span") {}\r
- \r
-#if NET_2_0\r
- protected\r
-#else\r
- public\r
-#endif\r
- HtmlControl(string tag)\r
- {\r
- _tagName = tag;\r
- }\r
- \r
- protected override ControlCollection CreateControlCollection ()\r
- {\r
- return new EmptyControlCollection (this);\r
- }\r
-\r
- internal static string AttributeToString(int n){\r
- if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);\r
- return null;\r
- }\r
- \r
- internal static string AttributeToString(string s){\r
- if (s != null && s.Length != 0) return s;\r
- return null;\r
- }\r
- \r
- internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){\r
- string attr = Attributes[attribName];\r
- if (attr != null){\r
- if (attr.Length != 0){\r
- try{\r
- attr = ResolveUrl(attr);\r
- }\r
- catch (Exception) {\r
- throw new HttpException(attribName + " property had malformed url");\r
- }\r
- writer.WriteAttribute(attribName, attr);\r
- Attributes.Remove(attribName);\r
- }\r
- }\r
- }\r
-\r
-#if NET_2_0\r
- /* keep these two methods in sync with the\r
- * IAttributeAccessor iface methods below */\r
- protected virtual string GetAttribute (string name)\r
- {\r
- return Attributes[name];\r
- }\r
-\r
- protected virtual void SetAttribute (string name, string value)\r
- {\r
- Attributes[name] = value;\r
- }\r
-#endif \r
- \r
- string System.Web.UI.IAttributeAccessor.GetAttribute(string name){\r
- return Attributes[name];\r
- }\r
- \r
- void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){\r
- Attributes[name] = value;\r
- }\r
- \r
- protected virtual void RenderBeginTag (HtmlTextWriter writer)\r
- {\r
- writer.WriteBeginTag (TagName);\r
- RenderAttributes (writer);\r
- writer.Write ('>');\r
- }\r
-\r
-#if NET_2_0\r
- protected internal\r
-#else\r
- protected\r
-#endif\r
- override void Render (HtmlTextWriter writer)\r
- {\r
- RenderBeginTag (writer);\r
- }\r
- \r
- protected virtual void RenderAttributes(HtmlTextWriter writer){\r
- if (ID != null){\r
- writer.WriteAttribute("id",ClientID);\r
- }\r
- Attributes.Render(writer);\r
- }\r
- \r
- [Browsable(false)]\r
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
- public AttributeCollection Attributes\r
- {\r
- get { \r
- if (_attributes == null)\r
- _attributes = new AttributeCollection (ViewState);\r
- return _attributes;\r
- }\r
- }\r
-\r
- [DefaultValue(false)]\r
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
- [WebCategory("Behavior")]\r
-#if NET_2_0\r
- /* Can't find this type in the docs */\r
- //[TypeConverter (typeof(System.Web.UI.MinimizableAttributeTypeConverter))]\r
-#endif\r
- public bool Disabled\r
- {\r
- get {\r
- string disableAttr = Attributes["disabled"] as string;\r
- return (disableAttr != null);\r
- }\r
- set {\r
- if (!value)\r
- Attributes.Remove ("disabled");\r
- else\r
- Attributes["disabled"] = "disabled";\r
- }\r
- }\r
-\r
- [Browsable(false)]\r
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
- public CssStyleCollection Style\r
- {\r
- get { return Attributes.CssStyle; }\r
- }\r
-\r
- [DefaultValue("")]\r
- [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]\r
- [WebCategory("Appearance")]\r
- public virtual string TagName\r
- {\r
- get { return _tagName; }\r
- }\r
-\r
- protected override bool ViewStateIgnoresCase \r
- {\r
- get {\r
- return true;\r
- }\r
- }\r
- }\r
-}\r
+//
+// System.Web.UI.HtmlControls.HtmlControl.cs
+//
+// Author
+// Bob Smith <bob@thestuff.net>
+//
+//
+// (C) Bob Smith
+// 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.
+//
+
+using System.ComponentModel;
+using System.ComponentModel.Design;
+using System.Globalization;
+using System.Security.Permissions;
+
+namespace System.Web.UI.HtmlControls{
+
+ // CAS
+ [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+ // attributes
+ [ToolboxItem(false)]
+ [Designer ("System.Web.UI.Design.HtmlIntrinsicControlDesigner, " + Consts.AssemblySystem_Design,
+ "System.ComponentModel.Design.IDesigner")]
+ public abstract class HtmlControl : Control, IAttributeAccessor
+ {
+ internal string _tagName;
+ AttributeCollection _attributes;
+
+
+#if NET_2_0
+ protected
+#else
+ public
+#endif
+ HtmlControl() : this ("span") {}
+
+#if NET_2_0
+ protected
+#else
+ public
+#endif
+ HtmlControl(string tag)
+ {
+ _tagName = tag;
+ }
+
+ protected override ControlCollection CreateControlCollection ()
+ {
+ return new EmptyControlCollection (this);
+ }
+
+ internal static string AttributeToString(int n){
+ if (n != -1)return n.ToString(NumberFormatInfo.InvariantInfo);
+ return null;
+ }
+
+ internal static string AttributeToString(string s){
+ if (s != null && s.Length != 0) return s;
+ return null;
+ }
+
+ internal void PreProcessRelativeReference(HtmlTextWriter writer, string attribName){
+ string attr = Attributes[attribName];
+ if (attr != null){
+ if (attr.Length != 0){
+ try{
+ attr = ResolveClientUrl(attr);
+ }
+ catch (Exception) {
+ throw new HttpException(attribName + " property had malformed url");
+ }
+ writer.WriteAttribute(attribName, attr, true);
+ Attributes.Remove(attribName);
+ }
+ }
+ }
+
+#if NET_2_0
+ /* keep these two methods in sync with the
+ * IAttributeAccessor iface methods below */
+ protected virtual string GetAttribute (string name)
+ {
+ return Attributes[name];
+ }
+
+ protected virtual void SetAttribute (string name, string value)
+ {
+ Attributes[name] = value;
+ }
+#endif
+
+ string System.Web.UI.IAttributeAccessor.GetAttribute(string name){
+ return Attributes[name];
+ }
+
+ void System.Web.UI.IAttributeAccessor.SetAttribute(string name, string value){
+ Attributes[name] = value;
+ }
+
+ protected virtual void RenderBeginTag (HtmlTextWriter writer)
+ {
+ writer.WriteBeginTag (TagName);
+ RenderAttributes (writer);
+ writer.Write ('>');
+ }
+
+#if NET_2_0
+ protected internal
+#else
+ protected
+#endif
+ override void Render (HtmlTextWriter writer)
+ {
+ RenderBeginTag (writer);
+ }
+
+ protected virtual void RenderAttributes(HtmlTextWriter writer){
+ if (ID != null){
+ writer.WriteAttribute("id",ClientID);
+ }
+ Attributes.Render(writer);
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public AttributeCollection Attributes
+ {
+ get {
+ if (_attributes == null)
+ _attributes = new AttributeCollection (ViewState);
+ return _attributes;
+ }
+ }
+
+ [DefaultValue(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("")]
+ [WebCategory("Behavior")]
+#if NET_2_0
+ [TypeConverter (typeof(MinimizableAttributeTypeConverter))]
+#endif
+ public bool Disabled
+ {
+ get {
+ string disableAttr = Attributes["disabled"] as string;
+ return (disableAttr != null);
+ }
+ set {
+ if (!value)
+ Attributes.Remove ("disabled");
+ else
+ Attributes["disabled"] = "disabled";
+ }
+ }
+
+ [Browsable(false)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ public CssStyleCollection Style
+ {
+ get { return Attributes.CssStyle; }
+ }
+
+ [DefaultValue("")]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [WebSysDescription("")]
+ [WebCategory("Appearance")]
+ public virtual string TagName
+ {
+ get { return _tagName; }
+ }
+
+ protected override bool ViewStateIgnoresCase
+ {
+ get {
+ return true;
+ }
+ }
+ }
+}