System.Web.Compilation.TagAttributes.Add C# (CSharp) Method

Add() public method

public Add ( object key, object value ) : void
key object
value object
return void
		public void Add (object key, object value)
		{
			if (key != null && value != null &&
			    0 == String.Compare ((string) key,  "runat", true, Helpers.InvariantCulture)) {
			    	if (0 != String.Compare ((string) value,  "server", true))
					throw new HttpException ("runat attribute must have a 'server' value");

				if (got_hashed)
					return; // ignore duplicate runat="server"

				MakeHash ();
			}

			if (value != null)
				value = HttpUtility.HtmlDecode (value.ToString ());

			if (got_hashed) {
				CheckServerKey (key);
				if (atts_hash.ContainsKey (key))
					throw new HttpException ("Tag contains duplicated '" + key +
								 "' attributes.");
				atts_hash.Add (key, value);
			} else {
				keys.Add (key);
				values.Add (value);
			}
		}
		

Usage Example

コード例 #1
0
        TagAttributes GetAttributes()
        {
            int           token;
            TagAttributes attributes;
            string        id;
            bool          wellFormedForServer = true;

            attributes = new TagAttributes();
            while ((token = tokenizer.get_token()) != Token.EOF)
            {
                if (token == '<' && Eat('%'))
                {
                    tokenizer.Verbatim = true;
                    attributes.Add(String.Empty, "<%" +
                                   GetVerbatim(tokenizer.get_token(), "%>") + "%>");
                    tokenizer.Verbatim = false;
                    tokenizer.InTag    = true;
                    continue;
                }

                if (token != Token.IDENTIFIER)
                {
                    break;
                }

                id = tokenizer.Value;
                if (Eat('='))
                {
                    if (Eat(Token.ATTVALUE))
                    {
                        attributes.Add(id, tokenizer.Value);
                        wellFormedForServer &= tokenizer.AlternatingQuotes;
                    }
                    else if (Eat('<') && Eat('%'))
                    {
                        tokenizer.Verbatim = true;
                        attributes.Add(id, "<%" +
                                       GetVerbatim(tokenizer.get_token(), "%>") + "%>");
                        tokenizer.Verbatim = false;
                        tokenizer.InTag    = true;
                    }
                    else
                    {
                        OnError("expected ATTVALUE");
                        return(null);
                    }
                }
                else
                {
                    attributes.Add(id, null);
                }
            }

            tokenizer.put_back();

            if (attributes.IsRunAtServer() && !wellFormedForServer)
            {
                OnError("The server tag is not well formed.");
                return(null);
            }

            return(attributes);
        }
All Usage Examples Of System.Web.Compilation.TagAttributes::Add