public void ToStringTest()
        {
            ElementAttributesDictionary target = new ElementAttributesDictionary();

            target.Add("Test1", "Test1");
            target.Add("Test2", "Test2");
            Assert.AreEqual(" Test1=\"Test1\" Test2=\"Test2\"", target.ToString());
        }
Example #2
0
        /// <summary>
        /// Returns this Widget rendered as HTML
        /// </summary>
        /// <param name="name">Form name of the widget being renderd</param>
        /// <param name="value">Value of the field being rendered</param>
        /// <param name="extraAttributes">Attributes to assign to HTML entity</param>
        /// <returns>HTML</returns>
        public override string Render(string name, object value, ElementAttributesDictionary extraAttributes)
        {
            ElementAttributesDictionary finalAttributes = BuildAttributes(extraAttributes);

            finalAttributes["type"] = this.inputType; // Override any other value
            finalAttributes.SetDefault("name", name);
            if (DisableAutoComplete)
            {
                finalAttributes.SetDefault("autocomplete", "off");
            }
            if (value != null)
            {
                string stringValue = value.ToString();
                if (!string.IsNullOrEmpty(stringValue))
                {
                    finalAttributes.SetDefault("value", stringValue);
                }
            }
            return(string.Format(CultureInfo.InstalledUICulture, "<input{0} />", finalAttributes.ToString()));
        }