app_themes and changing image button image

Posted on 2009-04-21
Last Modified: 2013-11-26

I have a panel which expands and collapses.
when ever the panel is expanded or collapsed, it shows a different image to indicate the panel is collapsed or expanded.

however, i need to drive this off the themes folder
please see the code below, when the panel is expanded image changes to exapnded.jpg, but i need these images to sit in the themes folder, and depending on what theme is active, it will pull in the relevent image

the problem is that this page is a shared user control (rules out having it on its own master page or creating a new control just for this)

how would i acheive this (a background image in CSS isn't an option either)

<asp:ImageButton CssClass="togglePanel" ID="ToggleImage" runat="server" ImageUrl="~/images/collapse.jpg" AlternateText="collapse" />

Open in new window

Question by:paulCardiff
    LVL 39

    Accepted Solution

    Your best bet would be to change the CssClass on the fly, but considering all the restrictions you imply you may not be able to access that property.

    The shared user control cannot be edited? I'd assume something like an externalized CssClass property on it, or something like CollapsedImageUrl and ExpandedImageUrl. If not, I hope you can change the user control. If not... options to do this neatly get slimmer...
    LVL 7

    Assisted Solution

    I assume you're using JS to switch the image and the collapse expand options client side. I've accomplished this by setting the existing theme names into a JS variable on page load. Then you reference that variable in the JS to make your change to the image onClick.

    So, on  page load server-side, add a javascript block that has the variables to hold the image name. Then use your existing theme to create the path to the Themes folder. Example, "../App_Themes/Blue/image/collapsed_Blue.gif".

    Then on your client side click event, change the img url to the ones you set in the JS variable on page load.
    LVL 39

    Expert Comment

    @dacIT: this was by long an abandoned question, but it is nice of you to still add some possible solutions. Maybe it will make the question alive again?

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK ( for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now