Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7191861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:49:06+00:00 2026-05-28T19:49:06+00:00

I actually have two questions: (1) Is it possible to put another image on

  • 0

I actually have two questions:

(1) Is it possible to put another image on top of an ImageButton that already has an ImageUrl set (without changing the ImageUrl – literally just add the second image ‘on top’)? Even by using CSS?

(2) I have a dynamically set number of ImageButtons contained within a ListView. When a user clicks on an ImageButton, I change the .CssClass property of the one clicked in order to ‘highlight’ it. My question is this: whenever an ImageButton is click, I need to not only highlight it, but make sure I unhighlight all the others. However, I’m having trouble getting the others. I get the clicked ImageButton using

((ImageButton)sender).CssClass = "SelectedImageButton";

in the event handler. However, how do I get all the others so I can set their style ‘back’ to the unhighlighted style?

Thanks in advance for any help!

UPDATE: ANSWERED!
I’ve solved the issue mentioned in (2) using the following algorithm. Note, I’ve marked @OFConsulting’s answer below as the correct answer because without his algorithm, I would have never gotten the following algorithm (which came from tweaking his algorithm slightly). Thanks @OFConsulting!

// Cast the sender to an ImageButton to have the clicked ImageButton
ImageButton clickedImageButton = sender as ImageButton;

// The ListView has ListViewDataItems and the ImageButtons are in 
// THOSE children controls, thus match on the ImageButtons' Parents' IDs
Control parentControl = clickedImageButton.Parent;
List<ListViewDataItem> allOtherImageButtons = MyListView.Controls.OfType<ListViewDataItem().AsQueryable().Where(i => i.ID != clickedImageButton.Parent.ID).ToList();

// Highlight
clickedImageButton.CssClass = "HighlightedStyle";

// Unhighlight
foreach (ListViewDataItem button in allOtherImageButtons)
{
    // The ImageButton is always the 2nd child control of the ListViewDataItem
    ImageButton childImageButton = (ImageButton)button.Controls[1];
    childImageButton.CssClass = "NoHighlightedStyle";
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:49:07+00:00Added an answer on May 28, 2026 at 7:49 pm

    For Part (1) of that question, setting the background image within your css class might do the trick, but you never really explained why you just couldn’t change the ImageUrl. You can always throw everything on an update panel if you need it to be dynamic without the hassle of a bunch of script.

    Part (2) seems pretty straight forward. Just use a little bit of linq against the relevant control collection within your page.

    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
    {
        ImageButton clickImageButton = sender as ImageButton;
    
        // This example assumes all the image buttons have the same parent.
        // Tweak as needed depending on the layout of your page
        Control parentControl = clickImageButton.Parent;
        List<ImageButton> allOtherImageButtons = parentControl.Controls.OfType<ImageButton>().AsQueryable().Where(i => i.ID != clickImageButton.ID).ToList();
    
        // Highlight
        clickImageButton.CssClass = "WhateverHighlights";
    
        // Unhighlight
        foreach (ImageButton button in allOtherImageButtons)
        {
            button.CssClass = "WhateverClears";
        }
    }
    

    Edit: One more thing. Make sure any controls you are adding dynamically get added before Page_Load (I.E. during Init). There are some viewstate issues associated with adding control too late.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I actually have two questions regarding exception/error handling in the iPhone app that I
I actually have two questions regarding the same problem but I think it is
Actually I have two questions. (1) Is there any reduction in processing power or
I actually have right now two questions: 1) What font faces are preferred for
I need an XML-serializable dictionary. Actually, I now have two quite different programs that
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually
I have actually two questions but they are kind of related so here they
I actually have two questions, I found the answer to the second and didn't
Actually i have two questions. Question 1. I have made a style for a
Actually, this question seems to have two parts: How to implement pattern matching? How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.