Merge pull request #1345 from mattleibow/websocket-continuation-frame-fix
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlImage.cs
index 2dbedd1945d7ca4316e13d2bcb6e0f7b32b36d6c..871e22e6ad9dbf83aa0f635b5c98eb995473abc1 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Dick Porter  <dick@ximian.com>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 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
@@ -29,6 +29,7 @@
 using System.ComponentModel;
 using System.Globalization;
 using System.Security.Permissions;
+using System.Web.Util;
 
 namespace System.Web.UI.HtmlControls 
 {
@@ -36,11 +37,7 @@ namespace System.Web.UI.HtmlControls
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
-#if NET_2_0
        [ControlBuilder (typeof (HtmlEmptyTagControlBuilder))]
-#else
-       [ControlBuilder (typeof (HtmlControlBuilder))]
-#endif
        public class HtmlImage : HtmlControl 
        {
                public HtmlImage () : base ("img")
@@ -51,8 +48,7 @@ namespace System.Web.UI.HtmlControls
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                [WebSysDescription("")]
                [WebCategory("Layout")]
-               public string Align 
-               {
+               public string Align {
                        get {
                                string align = Attributes["align"];
 
@@ -75,11 +71,8 @@ namespace System.Web.UI.HtmlControls
                [WebSysDescription("")]
                [WebCategory("Appearance")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-#if NET_2_0
                [Localizable (true)]
-#endif
-               public string Alt 
-               {
+               public string Alt {
                        get {
                                string alt = Attributes["alt"];
 
@@ -102,15 +95,14 @@ namespace System.Web.UI.HtmlControls
                [WebSysDescription("")]
                [WebCategory("Appearance")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public int Border 
-               {
+               public int Border {
                        get {
                                string border = Attributes["border"];
                                
                                if (border == null) {
                                        return (-1);
                                } else {
-                                       return (Int32.Parse (border, CultureInfo.InvariantCulture));
+                                       return (Int32.Parse (border, Helpers.InvariantCulture));
                                }
                        }
                        set {
@@ -126,15 +118,14 @@ namespace System.Web.UI.HtmlControls
                [WebSysDescription("")]
                [WebCategory("Layout")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public int Height
-               {
+               public int Height {
                        get {
                                string height = Attributes["height"];
                                
                                if (height == null) {
                                        return (-1);
                                } else {
-                                       return (Int32.Parse (height, CultureInfo.InvariantCulture));
+                                       return (Int32.Parse (height, Helpers.InvariantCulture));
                                }
                        }
                        set {
@@ -150,8 +141,8 @@ namespace System.Web.UI.HtmlControls
                [WebSysDescription("")]
                [WebCategory("Behavior")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public string Src 
-               {
+               [UrlProperty]
+               public string Src {
                        get {
                                string src = Attributes["src"];
 
@@ -174,8 +165,7 @@ namespace System.Web.UI.HtmlControls
                [WebSysDescription("")]
                [WebCategory("Layout")]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
-               public int Width 
-               {
+               public int Width {
                        get {
                                string width = Attributes["width"];
 
@@ -183,7 +173,7 @@ namespace System.Web.UI.HtmlControls
                                        return (-1);
                                }
                                else {
-                                       return (Int32.Parse (width, CultureInfo.InvariantCulture));
+                                       return (Int32.Parse (width, Helpers.InvariantCulture));
                                }
                        }
                        set {
@@ -198,6 +188,15 @@ namespace System.Web.UI.HtmlControls
                protected override void RenderAttributes (HtmlTextWriter w)
                {
                        PreProcessRelativeReference (w, "src");
+
+                       /* MS does not seem to render the src attribute if it
+                        * is empty. Firefox, at least, will fetch the current
+                        * page as the src="" if other img attributes exist.
+                        */
+                       string src = Attributes["src"];
+                       if (src == null || src.Length == 0)
+                               Attributes.Remove ("src");
+
                        base.RenderAttributes (w);
 
                        /* MS closes the HTML element at the end of
@@ -208,5 +207,3 @@ namespace System.Web.UI.HtmlControls
                }
        }
 }
-
-