Пример #1
0
        /// <summary>
        ///   Sets or removes the "disabled" attribute.
        /// </summary>
        /// <param name = "attributes">The attributes to modify.</param>
        /// <param name = "value">Specifies whether to set the "disabled" attribute. If set to false, this will remove the "disabled" attribute.</param>
        /// <returns>
        ///   The modified <see cref = "HtmlAttributes" /> instance.
        /// </returns>
        public static HtmlAttributes Disabled(
            this HtmlAttributes attributes,
            bool value = true)
        {
            if (value)
            {
                attributes["disabled"] = "disabled";
            }
            else
            {
                attributes.Remove("disabled");
            }

            return(attributes);
        }
Пример #2
0
        /// <summary>
        ///   Sets or removes the "selected" attribute.
        /// </summary>
        /// <param name = "attributes">The attributes to modify.</param>
        /// <param name = "value">Specifies whether to set the "selected" attribute. If set to false, this will remove the "selected" attribute.</param>
        /// <returns>
        ///   The modified <see cref = "HtmlAttributes" /> instance.
        /// </returns>
        public static HtmlAttributes Selected(
            this HtmlAttributes attributes,
            bool value = true)
        {
            if (value)
            {
                attributes["selected"] = "selected";
            }
            else
            {
                attributes.Remove("selected");
            }

            return(attributes);
        }
Пример #3
0
        /// <summary>
        ///   Sets or removes the "checked" attribute.
        /// </summary>
        /// <param name = "attributes">The attributes to modify.</param>
        /// <param name = "value">Specifies whether to set the "checked" attribute. If set to false, this will remove the "checked" attribute.</param>
        /// <returns>
        ///   The modified <see cref = "HtmlAttributes" /> instance.
        /// </returns>
        public static HtmlAttributes Checked(
            this HtmlAttributes attributes,
            bool value = true)
        {
            if (value)
            {
                attributes["checked"] = "checked";
            }
            else
            {
                attributes.Remove("checked");
            }

            return(attributes);
        }