Here, we learn how to Call JavaScript function from code behind page in ASP.Net.
First write javascript function in Head tag on HTML page.
<script type=”text/javascript” >
function AlertBox()
{alert(‘Hello MeeraAcademy’);
}
</script>
Design ASP.Net web page with one button control:
Write below code on Button click event for call javascript function:
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Attributes.Add(“onclick”, “AlertBox()”);
}
The Output of call javascript function from code behind in asp.net is: