How to change PrimaryIcon at client side

2 posts, 1 answers
  1. Barbaros Saglamtimur
    Barbaros Saglamtimur avatar
    110 posts
    Member since:
    Jul 2012

    Posted 10 May 2012 Link to this post

    Hi,

    I would like to change buttons PrimaryIcon at client side. I have used set_iconData(s) but no luck. It sets icon data (can get back correct values with get_iconData) but nothing changed at browser window. I have used repaint function and nothing changed either. Any thoughts?

    TIA

    PS:Here is my code;
    var s = { "primaryIconUrl": "../images/icons/EnableConvex24.png", "primaryHeight": "24px", "primaryWidth": "24px" };
    btnActivate.set_iconData(s);
    btnActivate.repaint();
  2. Answer
    Slav
    Admin
    Slav avatar
    1356 posts

    Posted 14 May 2012 Link to this post

    Hello Barbaros,

    If you need to change the RadButton icon on the client-side, I would suggest configuring the image via a CSS class and setting this class in the property Icon-PrimaryIconCssClass. When you want to switch the icons on the client, just remove the specified CSS class and add a new one that will set different background image.

    For your convenience I have attached a sample page that demonstrates the described approach. The solution is related to the primary RadButton icon, but it can easily be applied for the secondary one via the property Icon-SecondaryIconCssClass. Please use this sample as a reference for incorporating the feature into your actual project.

    Regards,
    Slav
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top