Example #1
0
        private void RenderGotoPage(HtmlTextWriter writer, int totalPages)
        {
            WebControl webControl = new WebControl(HtmlTextWriterTag.Span);

            webControl.Attributes.Add("class", this.SkipPanelCssClass);
            ControlCollection controls = webControl.Controls;
            object            arg      = this.PageIndex;
            string            arg2     = totalPages.ToString(CultureInfo.InvariantCulture);
            int num = this.TotalRecords;

            controls.Add(new LiteralControl($"第{arg}/{arg2}页 共{num.ToString(CultureInfo.InvariantCulture)}记录"));
            WebControl webControl2 = new WebControl(HtmlTextWriterTag.Input);

            webControl2.Attributes.Add("type", "text");
            webControl2.Attributes.Add("class", this.SkipTxtCssClass);
            System.Web.UI.AttributeCollection attributes = webControl2.Attributes;
            num = this.PageIndex;
            attributes.Add("value", num.ToString(CultureInfo.InvariantCulture));
            webControl2.Attributes.Add("size", "3");
            webControl2.Attributes.Add("id", "txtGoto");
            webControl.Controls.Add(webControl2);
            webControl.Controls.Add(new LiteralControl("页"));
            WebControl webControl3 = new WebControl(HtmlTextWriterTag.Input);

            webControl3.Attributes.Add("type", "button");
            webControl3.Attributes.Add("class", this.SkipBtnCssClass);
            webControl3.Attributes.Add("value", "确定");
            webControl3.Attributes.Add("onclick", $"location.href=AppendParameter('{this.PageIndexFormat}',  $.trim($('#txtGoto').val()));");
            webControl.Controls.Add(webControl3);
            webControl.RenderControl(writer);
        }
Example #2
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");
        }
Example #3
0
        public void InitialNoBag8()
        {
            AC             ac     = new AC(null);
            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());

            ac.Render(writer);
        }
Example #4
0
        public void InitialNoBag7()
        {
            AC             ac     = new AC(null);
            HtmlTextWriter writer = new HtmlTextWriter(new StringWriter());

            ac.AddAttributes(writer);
        }
Example #5
0
 private static void RemoveAttributeInCol(string attKey, System.Web.UI.AttributeCollection attCol)
 {
     if (attCol[attKey] != null)
     {
         attCol.Remove(attKey);
     }
 }
Example #6
0
        public void InitialNoBag10()
        {
            AC ac = new AC(null);
            CssStyleCollection css = ac.CssStyle;
            int i = css.Count;

            Assert.AreEqual(0, i, "InitialNoBag10");
        }
Example #7
0
        public void InitialNoBag11()
        {
            AC ac = new AC(null);
            CssStyleCollection css  = ac.CssStyle;
            ICollection        coll = css.Keys;

            Assert.AreEqual(0, coll.Count, "InitialNoBag11");
        }
Example #8
0
        public void InitialNoBag12()
        {
            AC ac = new AC(null);
            CssStyleCollection css = ac.CssStyle;
            string             v   = css["hola"];

            Assert.AreEqual(null, v, "InitialNoBag12");
        }
Example #9
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "RssFeedLink" /> class.
 /// </summary>
 public RssFeedLink()
 {
   this.Load += this.RssFeedLink_Load;
   this._attributeCollection = new AttributeCollection(this.ViewState);
   this._localizedLabel.LocalizedTag = "RSSFEED";
   this.ImageThemeTag = "RSSFEED";
   this._themeImage.CssClass = "RssFeedIcon";
 }
Example #10
0
 /// <summary>
 /// 构造函数,可确定相关客户端对象的类型。
 /// </summary>
 public SampleControl()
     :
     base(true, HtmlTextWriterTag.Div)
 {
     //在客户端,客户端控件对应的DomElement为DIV控件
     this.inputAttribute = new System.Web.UI.AttributeCollection(this.ViewState);
     this.samObject      = new SampleObject(SNTPClient.AdjustedTime, "LiShiMin", 188);
     this.CssClass       = "sampleControl";
 }
Example #11
0
        private void AddBasicAttributes(HtmlTextWriter writer)
        {
            string strAttrValue = string.Empty;

            if (this.ID != null)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, this.ClientID);
            }

            strAttrValue = this.AccessKey;
            if (strAttrValue.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, strAttrValue);
            }

            if (!this.Enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }

            int num = this.TabIndex;

            if (num != 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, num.ToString(NumberFormatInfo.InvariantInfo));
            }

            strAttrValue = this.ToolTip;
            if (strAttrValue.Length > 0)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, strAttrValue);
            }

            if (this.ControlStyleCreated)
            {
                this.ControlStyle.AddAttributesToRender(writer, this);
            }

            System.Web.UI.AttributeCollection attrs = this.Attributes;
            IEnumerator enumerator = attrs.Keys.GetEnumerator();

            while (enumerator.MoveNext())
            {
                string text = (string)enumerator.Current;

                if (string.Compare(text, "onclick", true) != 0)
                {
                    writer.AddAttribute(text, attrs[text]);
                }
            }

            if (AutoDisabled)
            {
                AppendOnClickEvent(writer);
            }
        }
Example #12
0
        /// <summary>
        /// Removes custom binding attributes from a webcontrol to avoid them being rendered.
        /// </summary>
        private void RemoveBindingAttributes(IWebDataBound dataBound, WebControl wc)
        {
            AttributeCollection attributeCollection = wc.Attributes;

            attributeCollection.Remove(ATTR_BINDINGTARGET);
            attributeCollection.Remove(ATTR_BINDINGSOURCE);
            attributeCollection.Remove(ATTR_BINDINGTYPE);
            attributeCollection.Remove(ATTR_BINDINGDIRECTION);
            attributeCollection.Remove(ATTR_BINDINGFORMATTER);
        }
Example #13
0
        /// <include file='doc\WebControl.uex' path='docs/doc[@for="WebControl.AddAttributesToRender"]/*' />
        /// <devdoc>
        ///    <para>
        ///       Adds to the specified writer those HTML attributes and styles that need to be
        ///       rendered.
        ///    </para>
        /// </devdoc>
        protected virtual void AddAttributesToRender(HtmlTextWriter writer)
        {
            if (this.ID != null)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Id, ClientID);
            }
            string s;

            if (flags[accessKeySet])
            {
                s = AccessKey;
                if (s.Length > 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Accesskey, s);
                }
            }
            if (!Enabled)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Disabled, "disabled");
            }
            if (flags[tabIndexSet])
            {
                int n = TabIndex;
                if (n != 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Tabindex, n.ToString(NumberFormatInfo.InvariantInfo));
                }
            }
            if (flags[toolTipSet])
            {
                s = ToolTip;
                if (s.Length > 0)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Title, s);
                }
            }

            if (ControlStyleCreated && !ControlStyle.IsEmpty)
            {
                // let the style add attributes
                ControlStyle.AddAttributesToRender(writer, this);
            }

            // add unknown attributes
            if (attrState != null)
            {
                AttributeCollection atrColl = Attributes;
                IEnumerator         keys    = atrColl.Keys.GetEnumerator();
                while (keys.MoveNext())
                {
                    string attrName = (string)(keys.Current);
                    writer.AddAttribute(attrName, atrColl[attrName]);
                }
            }
        }
Example #14
0
        /// <summary>
        /// <para>GetControlAttribute looks a the type of control and does it's best to find an AttributeCollection.</para>
        /// </summary>
        /// <param name="c">Control to find the AttributeCollection on</param>
        /// <param name="affectedControls">ArrayList that hold the controls that have been localized. This is later used for the removal of the key attribute.</param>
        /// <returns>A string containing the key for the specified control or null if a key attribute wasn't found</returns>
        internal static string GetControlAttribute(Control c, ArrayList affectedControls)
        {
            AttributeCollection ac = null;
            string key             = null;

            if (c is LiteralControl) // LiteralControls don't have an attribute collection
            {
                key = null;
                ac  = null;
            }
            else
            {
                if (c is WebControl)
                {
                    WebControl w = (WebControl)c;
                    ac  = w.Attributes;
                    key = ac[Localization.KeyName];
                }
                else
                {
                    if (c is HtmlControl)
                    {
                        HtmlControl h = (HtmlControl)c;
                        ac  = h.Attributes;
                        key = ac[Localization.KeyName];
                    }
                    else
                    {
                        if (c is UserControl)
                        {
                            UserControl u = (UserControl)c;
                            ac  = u.Attributes;
                            key = ac[Localization.KeyName];
                            // Use reflection to check for attribute key. This is a last ditch option
                        }
                        else
                        {
                            Type         controlType       = c.GetType();
                            PropertyInfo attributeProperty = controlType.GetProperty("Attributes", typeof(AttributeCollection));
                            if (attributeProperty != null)
                            {
                                ac  = (AttributeCollection)attributeProperty.GetValue(c, null);
                                key = ac[Localization.KeyName];
                            }
                        }
                    }
                } // If the key was found add this AttributeCollection to the list that should have the key removed during Render
            }
            if (key != null && affectedControls != null)
            {
                affectedControls.Add(ac);
            }
            return(key);
        }
Example #15
0
        static internal string GetControlAttribute(Control c, ArrayList affectedControls)
        {
            System.Web.UI.AttributeCollection ac = null;
            string key = null;

            if (c is LiteralControl)
            {
                key = null;
                ac  = null;
            }
            else
            {
                if (c is WebControl)
                {
                    WebControl w = (WebControl)c;
                    ac  = w.Attributes;
                    key = ac[Services.Localization.Localization.KeyName];
                }
                else
                {
                    if (c is HtmlControl)
                    {
                        HtmlControl h = (HtmlControl)c;
                        ac  = h.Attributes;
                        key = ac[Services.Localization.Localization.KeyName];
                    }
                    else
                    {
                        if (c is UserControl)
                        {
                            UserControl u = (UserControl)c;
                            ac  = u.Attributes;
                            key = ac[Services.Localization.Localization.KeyName];
                        }
                        else
                        {
                            Type         controlType       = c.GetType();
                            PropertyInfo attributeProperty = controlType.GetProperty("Attributes", typeof(System.Web.UI.AttributeCollection));
                            if (attributeProperty != null)
                            {
                                ac  = (System.Web.UI.AttributeCollection)attributeProperty.GetValue(c, null);
                                key = ac[Services.Localization.Localization.KeyName];
                            }
                        }
                    }
                }
            }
            if (key != null && affectedControls != null)
            {
                affectedControls.Add(ac);
            }
            return(key);
        }
Example #16
0
		/// <summary>
		/// This will add or modify an HTML attribute.  If the attribute does not exist, it will be added.   
		/// If the attribute exists, and it contains the value of attrValue, it is left unchanged.
		/// If the attribute exists, but does not contain the value of attrValue, attrValue is appended to the attribute's value
		/// </summary>
		public static void AddAttribute(AttributeCollection attributes, string attrKey, string attrValue)
		{
			string existingValue = attributes[attrKey];
			if (string.IsNullOrEmpty(existingValue))
			{
				attributes.Add(attrKey, attrValue);
			}
			else
			{
				if (!existingValue.Contains(attrValue))
					attributes[attrKey] += attrValue;
			}
		}
Example #17
0
        public void Count2()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            ac ["style"] = "padding: 0px; margin: 0px";
            Assert.AreEqual(1, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(2, ac.CssStyle.Count, "AttributeCollection.Count");

            ac ["style"] = null;
            Assert.AreEqual(0, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(0, ac.CssStyle.Count, "AttributeCollection.Count");
        }
Example #18
0
        public void Count1()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            ac.Add("style", "padding: 0px; margin: 0px");
            Assert.AreEqual(1, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(2, ac.CssStyle.Count, "AttributeCollection.Count");

            ac.Remove("style");
            Assert.AreEqual(0, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(0, ac.CssStyle.Count, "AttributeCollection.Count");
        }
Example #19
0
        public static void RemoveKeyAttribute(ArrayList affectedControls)
        {
            if (affectedControls == null)
            {
                return;
            }
            int i;

            for (i = 0; i <= affectedControls.Count - 1; i++)
            {
                System.Web.UI.AttributeCollection ac = (System.Web.UI.AttributeCollection)affectedControls[i];
                ac.Remove(Services.Localization.Localization.KeyName);
            }
        }
Example #20
0
        public void Count4()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            ac.CssStyle ["padding"] = "0px";
            ac.CssStyle ["margin"]  = "0px";
            Assert.AreEqual(1, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(2, ac.CssStyle.Count, "AttributeCollection.Count");

            ac.CssStyle.Value = null;
            Assert.AreEqual(0, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(0, ac.CssStyle.Count, "AttributeCollection.Count");
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            this.ControlStyle.AddAttributesToRender(writer, this);


            System.Web.UI.AttributeCollection collection1 = this.Attributes;
            IEnumerator enumerator1 = collection1.Keys.GetEnumerator();

            while (enumerator1.MoveNext())
            {
                string text2 = (string)enumerator1.Current;
                writer.AddAttribute(text2, collection1[text2]);
            }
        }
        private static void AssignRowNumbers(ControlCollection ctls, int itemRowNumber)
        {
            string MERGE_FIELD_ID_ATTR        = "fieldid";
            string MERGE_FIELD_ROWNUMBER_ATTR = "rownumber";
            string MERGE_FIELD_ISLOOP_ATTR    = "isloop";

            foreach (Control ctl in ctls)
            {
                System.Web.UI.HtmlControls.HtmlImage img = ctl as System.Web.UI.HtmlControls.HtmlImage;

                if (img != null)
                {
                    System.Web.UI.AttributeCollection attrs = img.Attributes;
                    int  fieldID = DataObject.safeDBFieldIntValue(attrs[MERGE_FIELD_ID_ATTR]);
                    bool isLoop  = DataObject.safeDBFieldBooleanValue(attrs[MERGE_FIELD_ISLOOP_ATTR]);

                    if (fieldID > 0)
                    {
                        if (!isLoop)
                        {
                            string rowNumAttr = attrs[MERGE_FIELD_ROWNUMBER_ATTR];

                            if (rowNumAttr == null)
                            {
                                rowNumAttr = "";
                            }

                            if (rowNumAttr.Length > 0)
                            {
                                rowNumAttr = string.Concat(itemRowNumber, "_", rowNumAttr);
                            }
                            else
                            {
                                rowNumAttr = itemRowNumber.ToString();
                            }

                            attrs[MERGE_FIELD_ROWNUMBER_ATTR] = rowNumAttr;
                        }

                        attrs["runat"] = "server";
                    }
                }

                if (ctl.Controls.Count > 0)
                {
                    AssignRowNumbers(ctl.Controls, itemRowNumber);
                }
            }
        }
Example #23
0
        public void Count3()
        {
            StateBag bag = new StateBag(true);
            AC       ac  = new AC(bag);

            ac.CssStyle.Add("padding", "0px");
            ac.CssStyle.Add("margin", "0px");
            Assert.AreEqual(1, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(2, ac.CssStyle.Count, "AttributeCollection.Count");

            ac.CssStyle.Remove("padding");
            ac.CssStyle.Remove("margin");
            Assert.AreEqual(0, ac.Count, "AttributeCollection.Count");
            Assert.AreEqual(0, ac.CssStyle.Count, "AttributeCollection.Count");
        }
Example #24
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);
		}
Example #25
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["name"] != null)
            {
            }
            else
            {
                Response.Redirect("webform1.aspx");
            }


            if (Session["type"].ToString() == "false")
            {
                TextBox1.Visible = false;
                Button1.Visible  = false;
            }
            try
            {
                string DBHost     = "127.0.0.1";
                string DBName     = "base";
                string DBUserName = "******";
                string DBPassword = "******";

                string Conn_String = "server=" + DBHost + ";uid=" + DBUserName + ";password="******";database=" + DBName + ";";


                MySqlConnection Conn = new MySqlConnection(Conn_String);
                Conn.Open();

                MySqlCommand cmd;
                cmd = new MySqlCommand("SELECT link FROM live ORDER BY ID DESC LIMIT 1;", Conn);
                r   = (String)cmd.ExecuteScalar();
                //Label1.Text = r;

                //  frame1.Attributes.Add("src", "https://www.youtube.com/embed/JGwWNGJdvx8");
                System.Web.UI.AttributeCollection aCol = frame1.Attributes;
                aCol.Add("src", r);


                Conn.Close();
            }
            catch (Exception eX)
            {
                //Label1.Text += eX.ToString();
            }
        }
Example #26
0
 void IRepeatInfoUser.RenderItem(ListItemType itemType, int repeatIndex, RepeatInfo repeatInfo, HtmlTextWriter writer)
 {
     writer.WriteBeginTag("input");
     writer.WriteAttribute("type", "checkbox");
     writer.WriteAttribute("name", UniqueID);
     writer.WriteAttribute("id", ClientID + "_" +
                           repeatIndex.ToString(NumberFormatInfo.InvariantInfo));
     writer.WriteAttribute("value", Items[repeatIndex].Value);
     System.Web.UI.AttributeCollection attrs = Items[repeatIndex].Attributes;
     foreach (string key in attrs.Keys)
     {
         writer.WriteAttribute(key, attrs[key]);
     }
     writer.Write(">");
     writer.WriteBeginTag("label");
     writer.Write(">");
     writer.Write(Items[repeatIndex].Text);
     writer.WriteEndTag("label");
 }
Example #27
0
        public void NonStyleAttributes2()
        {
            StateBag       bag    = new StateBag(true);
            AC             ac     = new AC(bag);
            StringWriter   sr     = new StringWriter();
            HtmlTextWriter writer = new HtmlTextWriter(sr);

            ac.Add("class", "classname");
            ac.AddAttributes(writer);
            string str = sr.ToString();

            Assert.AreEqual("", str, "value1");
            Assert.AreEqual(1, bag.Count, "count1");
            writer = new HtmlTextWriter(sr);
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            ac.AddAttributes(writer);
            writer.RenderEndTag();
            Assert.AreEqual("", str, "value2");
            Assert.AreEqual(1, bag.Count, "count2");
        }
Example #28
0
        public static void AddTextBoxAttributes(Control ctrl, string attr, string val, bool recurse)
        {
            if (ctrl is TextBox)
            {
                System.Web.UI.AttributeCollection attrs = ((TextBox)ctrl).Attributes;
                IEnumerable <string> keys = attrs.Keys.Cast <string>();

                if (!keys.Contains(attr))
                {
                    ((TextBox)ctrl).Attributes.Add(attr, val);
                }
            }

            // recurse
            if (recurse)
            {
                foreach (Control c in ctrl.Controls)
                {
                    AddTextBoxAttributes(c, attr, val, true);
                }
            }
        }
Example #29
0
        public void InitialNoBag5()
        {
            AC ac = new AC(null);

            ac.Add("att", "value");
        }
Example #30
0
 public void InitialNoBag3()
 {
     AC          ac   = new AC(null);
     ICollection coll = ac.Keys;
 }
Example #31
0
		public void InitialNoBag4 ()
		{
			AC ac = new AC (null);
			string k = ac ["hola"];
		}
Example #32
0
		public void InitialNoBag6 ()
		{
			AC ac = new AC (null);
			ac.Clear ();
		}
Example #33
0
 public virtual bool ParseAttributes(AttributeCollection c)
 {
     c.Clear();
     bool res = true;
     while (CurrentToken != EndOfDocument && CurrentToken.Class == TokenClass.Identifier) {
         var a = c.New<Attribute>();
         if (!ParseAttribute(a)) res = false;
     }
     return res;
 }
Example #34
0
 /// <summary>
 /// 构造函数,可确定相关客户端对象的类型。
 /// </summary>
 public SampleControl()
     :
     base(true, HtmlTextWriterTag.Div)
 {
     //在客户端,客户端控件对应的DomElement为DIV控件
     this.inputAttribute = new System.Web.UI.AttributeCollection(this.ViewState);
     this.samObject = new SampleObject(DateTime.Now, "LiShiMin", 188);
     this.CssClass = "sampleControl";
 }
Example #35
0
		public void Count2 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			ac ["style"] = "padding: 0px; margin: 0px";
			Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");

			ac ["style"] = null;
			Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="AttributeCollectionAdapter"/> class.
		/// </summary>
		/// <param name="collection">The collection.</param>
		public AttributeCollectionAdapter(AttributeCollection collection)
		{
			_collection = collection;
		}
Example #37
0
		public void Count3 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			ac.CssStyle.Add("padding", "0px");
			ac.CssStyle.Add("margin", "0px");
			Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");

			ac.CssStyle.Remove ("padding");
			ac.CssStyle.Remove ("margin");
			Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
		}
Example #38
0
 public CtlHelper(AttributeCollection attributes)
 {
     ControlAttributes = attributes;
 }
        /// <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();
        }
Example #40
0
		public void Count1 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			ac.Add ("style", "padding: 0px; margin: 0px");
			Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");
			
			ac.Remove ("style");
			Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
		}
Example #41
0
		public void InitialNoBag9 ()
		{
			AC ac = new AC (null);
			ac.Remove ("hola");
		}
Example #42
0
		public void NonStyleAttributes2 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			StringWriter sr = new StringWriter ();
			HtmlTextWriter writer = new HtmlTextWriter (sr);
			ac.Add ("class", "classname");
			ac.AddAttributes (writer);
			string str = sr.ToString ();
			Assert.AreEqual ("", str, "value1");
			Assert.AreEqual (1, bag.Count, "count1");
			writer = new HtmlTextWriter (sr);
			writer.RenderBeginTag (HtmlTextWriterTag.A);
			ac.AddAttributes (writer);
			writer.RenderEndTag ();
			Assert.AreEqual ("", str, "value2");
			Assert.AreEqual (1, bag.Count, "count2");
		}
Example #43
0
		public void InitialNoBag7 ()
		{
			AC ac = new AC (null);
			HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
			ac.AddAttributes (writer);
		}
Example #44
0
		public void InitialNoBag8 ()
		{
			AC ac = new AC (null);
			HtmlTextWriter writer = new HtmlTextWriter (new StringWriter ());
			ac.Render (writer);
		}
Example #45
0
		public void InitialNoBag5 ()
		{
			AC ac = new AC (null);
			ac.Add ("att", "value");
		}
Example #46
0
		public void InitialNoBag2 ()
		{
			AC ac = new AC (null);
			int i = ac.Count;
		}
Example #47
0
 public void InitialNoBag2()
 {
     AC  ac = new AC(null);
     int i  = ac.Count;
 }
Example #48
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");
		}
Example #49
0
 public void InitialNoBag4()
 {
     AC     ac = new AC(null);
     string k  = ac ["hola"];
 }
Example #50
0
		public void InitialNoBag12()
		{
		    AC ac = new AC(null);
		    CssStyleCollection css = ac.CssStyle;
		    string v = css["hola"];
		    Assert.AreEqual(null, v, "InitialNoBag12");
		}
Example #51
0
        public void InitialNoBag6()
        {
            AC ac = new AC(null);

            ac.Clear();
        }
Example #52
0
		public void InitialNoBag11()
		{
		    AC ac = new AC(null);
		    CssStyleCollection css = ac.CssStyle;
		    ICollection coll = css.Keys;
		    Assert.AreEqual(0, coll.Count, "InitialNoBag11");
		}
Example #53
0
		public void InitialNoBag3 ()
		{
			AC ac = new AC (null);
			ICollection coll = ac.Keys;
		}
Example #54
0
		public void InitialNoBag10()
		{
		    AC ac = new AC(null);
		    CssStyleCollection css = ac.CssStyle;
		    int i = css.Count;
		    Assert.AreEqual(0, i, "InitialNoBag10");
		}
        private static string GetAttributeFromField(string key, AttributeCollection list)
        {
            if (list.Count.Equals(0)) return string.Empty;

            return list.Keys.Cast<object>().Any(k => k.ToString().ToLower().Equals(key.ToLower())) ? list[key] : string.Empty;
        }
Example #56
0
		public void Count4 ()
		{
			StateBag bag = new StateBag (true);
			AC ac = new AC (bag);
			ac.CssStyle ["padding"] = "0px";
			ac.CssStyle ["margin"] = "0px";
			Assert.AreEqual (1, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (2, ac.CssStyle.Count, "AttributeCollection.Count");

			ac.CssStyle.Value = null;
			Assert.AreEqual (0, ac.Count, "AttributeCollection.Count");
			Assert.AreEqual (0, ac.CssStyle.Count, "AttributeCollection.Count");
		}
Example #57
0
		private void RunSubTests(ref AttributeCollection attributes)
		{
			this.GHTSubTestBegin("Attributes Keys count");
			try
			{
				this.GHTSubTestAddResult(attributes.Count.ToString());
			}
			catch (Exception exception4)
			{
				// ProjectData.SetProjectError(exception4);
				Exception exception1 = exception4;
				this.GHTSubTestUnexpectedExceptionCaught(exception1);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			this.GHTSubTestBegin("Attributes Values count");
			try
			{
				this.GHTSubTestAddResult(attributes[attributes.Count.ToString()]);
			}
			catch (Exception exception5)
			{
				// ProjectData.SetProjectError(exception5);
				Exception exception2 = exception5;
				this.GHTSubTestUnexpectedExceptionCaught(exception2);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
			this.GHTSubTestBegin("Attributes Keys+Values ");
			try
			{
				IEnumerator enumerator1 = null;
				string text1 = string.Empty + "<AttributeContainer ";
				try
				{
					enumerator1 = attributes.Keys.GetEnumerator();
					while (enumerator1.MoveNext())
					{
						string text2 = (string)(enumerator1.Current);
						string[] textArray1 = new string[] { text1, " ", text2, "=", attributes[text2], " " } ;
						text1 = string.Concat(textArray1);
					}
				}
				finally
				{
					if (enumerator1 is IDisposable)
					{
						((IDisposable) enumerator1).Dispose();
					}
				}
				text1 = text1 + "></AttributeContainer>";
				this.GHTSubTestAddResult(text1);
			}
			catch (Exception exception6)
			{
				// ProjectData.SetProjectError(exception6);
				Exception exception3 = exception6;
				this.GHTSubTestUnexpectedExceptionCaught(exception3);
				// ProjectData.ClearProjectError();
			}
			this.GHTSubTestEnd();
		}
Example #58
0
		public void InitialNoBag1 ()
		{
			AC ac = new AC (null);
			Assert.IsNotNull (ac.CssStyle, "style");
		}
Example #59
0
 /// <summary>
 ///   Initializes a new instance of the <see cref = "ThemeButton" /> class.
 /// </summary>
 public ThemeButton()
 {
     this.Load += this.ThemeButton_Load;
     this._attributeCollection = new AttributeCollection(ViewState);
 }
		internal void CopyFrom (AttributeCollection attributeCollection)
		{
			if (attributeCollection == null || attributeCollection.Count == 0)
				return;

			foreach (string key in attributeCollection.bag.Keys)
				this.Add (key, attributeCollection [key]);
		}