Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

140
Views
Image appears after checking checkbox in HTML
protected void btnSubmit_Click(object sender, EventArgs e)
    {

        imgPurple.Visible = true;
    }

For now, I am able to make the imgPurple appear after I click btnSubmit. However, thats not what I want.

I want the imgPurple to appear when I check a checkbox, not button. How do I achieve that?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Do you have AutoPostBack set to true? The button you have tried will cause a postback but a checkbox change won't postback by default. This works:

<asp:CheckBox ID="CheckBox1" AutoPostBack="true" OnCheckedChanged="CheckBox1_CheckedChanged" runat="server" />

With the following:

protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        imgPurple.Visible = true;
    } 
about 4 years ago · Juan Pablo Isaza Report

0

I'm no expert in C# or .NET(If that's even the language it is), but if you compare the previous values with the current values and they are not the same, then they have changed.

So save the previous state into an object, and compare that object with the current state.

Another note, since you're not using a button as the event target, you'll probably want to use something like @Bobney was suggesting as the event handler like OnCheckedChanged as opposed to BtnSubmit_Click.

about 4 years ago · Juan Pablo Isaza Report

0

HTML with JavaScript:

<html>
<head>
<script>
function showPic()
{
    if (document.getElementById("myCb").checked === true)
    {
        //document.getElementById("myPic").style.display = "inline";
        document.getElementById("myPic").style.visibility = "visible";
    }
    else
    {
        //document.getElementById("myPic").style.display = "none";
        document.getElementById("myPic").style.visibility = "hidden";
    }
}
</script>
</head>
<body onload="showPic();">

<input id="myCb" type="checkbox" onclick="showPic();" /><br />
<br /> 
<img id="myPic" src="myPic.png" alt="myPic" />

</body>
</html>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!