Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

142
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda