public void When_rendering_CssStyle_Then_has_proper_attributes()
        {
            var control = new CssStyle("body { color: red; }");

            string actual  = control.ToString();
            var    element = this.GetHtmlNode(actual);

            Assert.That(element.Name, Is.EqualTo("style"));
            Assert.That(element.InnerText.Trim(), Is.EqualTo("body { color: red; }"));
            Assert.That(element.Attributes["type"].Value, Is.EqualTo("text/css"));
            Assert.That(element.Attributes["src"], Is.Null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 设置样式值
        /// </summary>
        /// <param name="name">样式名</param>
        /// <param name="value">样式值(若为 null 则移除样式)</param>
        /// <returns>样式管理器自身</returns>
        public virtual StyleManager SetValue(string name, string value)
        {
            lock (_element.SyncRoot)
            {
                EnsureStyle();

                _style[name] = value;

                _element.SetAttribute("style", _style.ToString(), out _attribute);

                return(this);
            }
        }
Exemplo n.º 3
0
 void Ctrl_PreRender(object sender, EventArgs e)
 {
     Ctrl.Attributes.Add("style", CssStyle.ToString());
 }