示例#1
0
        public void InitialBag1()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            Assert.AreEqual(0, ac.Count, "count");
            Assert.AreEqual(null, ac ["hola"], "item");
            Assert.AreEqual(0, ac.Keys.Count, "keys");
            ac.Add("notexists", "invalid");
            ac.Remove("notexists");
            ac.Remove("notexists");

            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());

            ac.AddAttributes(writer);
            ac.Render(writer);
            Assert.AreEqual(0, writer.InnerWriter.ToString().Length, "length");
            CssStyleCollection css = ac.CssStyle;

            Assert.AreEqual(0, css.Count, "csscount");
            Assert.AreEqual(null, css ["hola"], "cssitem");
            Assert.AreEqual(0, css.Keys.Count, "csskeys");
            css.Add("notexists", "invalid");
            css.Remove("notexists");
            css.Remove("notexists");
            css.Add("notexists", "invalid");
            css.Clear();
            Assert.AreEqual(0, css.Keys.Count, "csskeys2");
        }
示例#2
0
        public void InitialNoBag8()
        {
            AC             ac     = new AC(null);
            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());

            ac.Render(writer);
        }
示例#3
0
		public void Deny_Unrestricted ()
		{
			// nothing else is required
			AttributeCollection ac = new AttributeCollection (bag);

			Assert.AreEqual (0, ac.Count, "Count");
			Assert.IsNotNull (ac.CssStyle, "CssStyle");
			ac["mono"] = "monkey";
			Assert.AreEqual ("monkey", ac["mono"], "this");
			Assert.IsNotNull (ac.Keys, "Keys");

			ac.Add ("monkey", "mono");
			ac.AddAttributes (writer);
			ac.Clear ();
			ac.Remove ("mono");
			ac.Render (writer);
		}
        /// <summary>
        /// Writes the option.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <param name="writer">The writer.</param>
        private void WriteOption(ExtendedListItem item, HtmlTextWriter writer)
        {
            writer.WriteBeginTag("option");
            if (item.Selected)
            {
                if (_selected)
                {
                    this.VerifyMultiSelect();
                }
                _selected = true;
                writer.WriteAttribute("selected", "selected");
            }

            if (!string.IsNullOrEmpty(item.CssClass))
                writer.WriteAttribute("class", item.CssClass);

            writer.WriteAttribute("value", item.Value, true);

            if (item.Attributes.Count > 0)
            {
                StateBag bag = new StateBag();
                foreach (string attrKey in item.Attributes.Keys)
                {
                    if (attrKey.IndexOf(ExtendedListItem._attrPrefix) == -1)
                        bag.Add(attrKey, item.Attributes[attrKey]);
                }

                System.Web.UI.AttributeCollection coll = new System.Web.UI.AttributeCollection(bag);

                coll.Render(writer);
            }

            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterForEventValidation(this.UniqueID, item.Value);
            }

            writer.Write('>');
            HttpUtility.HtmlEncode(item.Text, writer);
            writer.WriteEndTag("option");
            writer.WriteLine();
        }
示例#5
0
		public void InitialNoBag8 ()
		{
			AC ac = new AC (null);
			HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
			ac.Render (writer);
		}
示例#6
0
		public void InitialBag1 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			Assert.AreEqual (0, ac.Count, "count");
			Assert.AreEqual (null, ac ["hola"], "item");
			Assert.AreEqual (0, ac.Keys.Count, "keys");
			ac.Add ("notexists", "invalid");
			ac.Remove ("notexists");
			ac.Remove ("notexists");

			HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
			ac.AddAttributes (writer);
			ac.Render (writer);
			Assert.AreEqual (0, writer.InnerWriter.ToString().Length, "length");
			CssStyleCollection css = ac.CssStyle;
			Assert.AreEqual (0, css.Count, "csscount");
			Assert.AreEqual (null, css ["hola"], "cssitem");
			Assert.AreEqual (0, css.Keys.Count, "csskeys");
			css.Add ("notexists", "invalid");
			css.Remove ("notexists");
			css.Remove ("notexists");
			css.Add ("notexists", "invalid");
			css.Clear ();
			Assert.AreEqual (0, css.Keys.Count, "csskeys2");
		}