protected override void OnPreRender(EventArgs e) { if (body != null && !String.IsNullOrEmpty(TabSectionId)) { ControlHelper.AddCssClass(body, TabSectionId); } }
static void SetButtonStyle(Control control) { var button = control as Button; if (button != null) { ControlHelper.AddCssClass(button, "button"); } }
static void SetTextBoxStyle(Control control) { var textBox = control as TextBox; if (textBox != null) { if (textBox.TextMode == TextBoxMode.SingleLine || textBox.TextMode == TextBoxMode.Password) { ControlHelper.AddCssClass(textBox, "textbox"); } if (textBox.TextMode == TextBoxMode.MultiLine) { ControlHelper.AddCssClass(textBox, "textarea"); } } }
public void OnlyAddCssClassWhenNotAlreadyThere() { var label = new Label(); label.CssClass = "foo bar baz quux"; ControlHelper.AddCssClass(label, "baz"); Assert.AreEqual("foo bar baz quux", label.CssClass); ControlHelper.AddCssClass(label, "click"); Assert.AreEqual("foo bar baz quux click", label.CssClass); label.CssClass = "click"; ControlHelper.AddCssClass(label, "click"); Assert.AreEqual("click", label.CssClass); label.CssClass = ""; ControlHelper.AddCssClass(label, "click"); Assert.AreEqual("click", label.CssClass); label.CssClass = "click"; ControlHelper.AddCssClass(label, "cluck"); Assert.AreEqual("click cluck", label.CssClass); }