HtmlAttributeEncode() 공개 정적인 메소드

Encode an HTML attribute value.
Encodes an HTML attribute value.
/// is null. /// /// and do not specify /// a valid range in the value. /// /// is not a valid quote character. ///
public static HtmlAttributeEncode ( char value, int startIndex, int count, char quote = '"' ) : string
value char The attribute value to encode.
startIndex int The starting index of the attribute value.
count int The number of characters in the attribute value.
quote char The character to use for quoting the attribute value.
리턴 string
예제 #1
0
        /// <summary>
        /// Write the HTML tag to a <see cref="System.IO.TextWriter"/>.
        /// </summary>
        /// <remarks>
        /// Writes the HTML tag to a <see cref="System.IO.TextWriter"/>.
        /// </remarks>
        /// <param name="output">The output.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="output"/> is <c>null</c>.
        /// </exception>
        public override void WriteTo(TextWriter output)
        {
            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }

            output.Write('<');
            if (IsEndTag)
            {
                output.Write('/');
            }
            output.Write(Name);
            for (int i = 0; i < Attributes.Count; i++)
            {
                output.Write(' ');
                output.Write(Attributes[i].Name);
                if (Attributes[i].Value != null)
                {
                    output.Write('=');
                    HtmlUtils.HtmlAttributeEncode(output, Attributes[i].Value);
                }
            }
            if (IsEmptyElement)
            {
                output.Write('/');
            }
            output.Write('>');
        }
예제 #2
0
        void EncodeAttributeValue(string value)
        {
            if (WriterState != HtmlWriterState.Attribute)
            {
                throw new InvalidOperationException("Attribute values can only be written in the Attribute state.");
            }

            html.Write('=');
            HtmlUtils.HtmlAttributeEncode(html, value);
            WriterState = HtmlWriterState.Tag;
        }
예제 #3
0
        void EncodeAttributeValue(char[] value, int startIndex, int count)
        {
            if (WriterState != HtmlWriterState.Attribute)
            {
                throw new InvalidOperationException("Attribute values can only be written in the Attribute state.");
            }

            html.Write('=');
            HtmlUtils.HtmlAttributeEncode(html, value, startIndex, count);
            WriterState = HtmlWriterState.Tag;
        }