Conditionally supress the background image in the Black skin

5 posts, 1 answers
  1. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 12 Dec 2011 Link to this post

    I've got a control based on the RadTextbox.

    My control has a IsMandatory property and I'm doing something like this in the control...
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (isMandatory)
        {
            RadTextBox1.EnabledStyle.BackColor = System.Drawing.Color.Pink;
        }
    }
    This works a treat.

    Except when the skin is Black. The black skin renders an image in the background of the textbox.

    I need to supress this when my input control has IsMandatory = true

    --
    Stuart

  2. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 13 Dec 2011 Link to this post

    I perhaps should have said, for the casual reader, that 'background (or background-image) isn't available as a property to set on the 'EnabledStyle' property.

    --
    Stuart
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 14 Dec 2011 Link to this post

    Hello Stuart,

    I'm assuming it would be easier to suppress the background-image if you set the CssClass used by the EnabledStyle. Then in the css style, you could highlight it pink and hide the background-image.
  5. Answer
    Tsvetina
    Admin
    Tsvetina avatar
    1876 posts

    Posted 14 Dec 2011 Link to this post

    Hello Stuart,

    As Kevin also said, you should use a CSS rule to overwrite the background image. The following should work for you:
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        if (isMandatory)
        {
            RadTextBox1.EnabledStyle.CssClass = "custom";  
        }
    }
    html body span.RadInput input.custom
    {
        background:pink;
    }

    The above CSS rule will be applied regardless of the skin chosen.

    Greetings,
    Tsvetina
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  6. Stuart Hemming
    Stuart Hemming avatar
    1622 posts
    Member since:
    Jul 2004

    Posted 19 Dec 2011 Link to this post

    Kevin, Tsvetina,

    Thanks both for the suggestions.

    I had tried changing the style that way, but hadn't gottent the selector right.

    I have it now.

    Many thanks

    --
    Stuart
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017