Latest Job

How to call JavaScript method from code behind in Asp.Net


Here we will learn how to call java script methods form code behind and how to call click method of html button.


Create an java script method

  <script>   function ShowPopup() {
      $("#btnShowPopup").click();
  }
</script>

Create a Button.

<button type="button" onclick=" ShowPopup();" class="close" data-dismiss="modal">
                      </button>

Call javascript method from code behind.

protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
}

Comment here