Alert with ajax in c #

1

Good, I would like to know how I can make an alert appear when I press a button, but with ajax (using jquery better), that is to say without recharging the page. The code that I have now with which I reload the page is the following:

     protected void btn_cambiarContra_Click(object sender, EventArgs e)
       {
        if (nuevo_Password.Text==repetir_Password.Text)
        {


            ClientScript.RegisterStartupScript(this.GetType(),"myScript", "<script>alert('Las contraseñas coinciden');</script>");

        }else
        {
            ClientScript.RegisterStartupScript(this.GetType(), "myScript", "<script>alert('Las contraseñas NO coinciden');</script>");
        }
       }
    
asked by wuasaa 25.12.2016 в 02:21
source

1 answer

1

Do it from the client use the onclick event of the button:

$(document).ready(function () {
    $("#btn_cambiarContra").click(function () {
        if($("#nuevo_Password").val() == $("#repetir_Password").val()){
            alert('Las contraseñas coinciden');
        }
        else{
            alert('Las contraseñas NO coinciden');
        }
    });
});
    
answered by 26.12.2016 / 20:03
source