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 8248901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:21:10+00:00 2026-06-07T23:21:10+00:00

I have anchor tag with one image tag inside, I am dynamically changing the

  • 0

I have anchor tag with one image tag inside, I am dynamically changing the image inside the anchor tag based on button click. button1 to set Red.png image, button2 to set Green.png image . I want to validate which image inside the anchor tag and if it is Green.png i need to show the thickbox if it is Red.png no action should not take place. how i can do this?

//my aspx code-Anchor tag with image tag

<a onclick="validate();" href="PopUpPage.aspx?KeepThis=true&TB_iframe=true&height=150&width=400"
      class="thickbox" id="AnchorImage" >
<img id="ColorImageButton" src="SiteImages/Red.png" runat="server" />
</a>

//two button- button1 to set red image, button2 to set green image

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
<asp:Button ID="Button2" runat="server" onclick="Button2_Click" Text="Button" />

    protected void Button1_Click(object sender, EventArgs e)
    {
        ColorImageButton.Src = "~/SiteImages/Red.png";
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        ColorImageButton.Src = "~/SiteImages/Green.png";
    }

Update: Based on answers I added a JavaScript to remove link but still i have black screen background of thickbox

function validate() {

    if (document.getElementById('<%=ColorImageButton.ClientID%>').src.indexOf('Red.png') >= 0) {
                         document.getElementById('AnchorImage').removeAttribute('href');
    }
  • 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-06-07T23:21:12+00:00Added an answer on June 7, 2026 at 11:21 pm

    With Javascript you could do something like this:

    1. Attach an onclick handler to the anchor as so:

      <a onclick="validate();" href="PopUpPage.aspx?KeepThis=true&TB_iframe=true&height=150&width=400"
        class="thickbox" id="AnchorImage"  >
      <img id="ColorImageButton" src="SiteImages/Red.png" runat="server" />
      </a>
      
    2. Define the validate function:

      ​function validate()
      {
         //If image is red; change the href value to a hash sign
         //so it doesn't do anything
         if(document.getElementById('<%=ColorImageButton.ClientID%>').src.indexOf('Red.png')>=0)
         {
            document.getElementById('AnchorImage').href='#';
         }
      }​
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an anchor tag <a class=next>next</a> made into a button. Sometimes, this tag
I have a textbox inside the anchor tag. And I want to get its
I have an image tag enclosed in an anchor element like this: <a href='$image'><img
Here is my problem: I have a large anchor tag that links to one
I tried to use more than one click handler for anchor tag . One
I have a jquery which has a click event, when any anchor tag is
I'm working with jquery. I have an anchor tag that is generated dynamically in
I have one aspx page with 1000 anchor tag. I want to open single
I have two elements (a button and an anchor tag) both with a dynamical
I have an anchor tag with some simple CSS: div { background-color: gray; /*

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.