Call JavaScript function from c# Code behind (Server Side) in

In this asp .net tutorial we will learn how to call JavaScript function from asp .net code behind. We will cover following scenarios in this tutorial: Call JavaScript function from asp .net code behind. Call JavaScript function from asp .net code behind and pass values to the function. Create functions in JavaScript


Explanation: First function "showAlert" will display alert message box and second function "sumValues" will take 2 arguments and displays their sum in alert box.

Call JavaScript function without arguments.


 protected void btnShowAlert_Click(object sender, EventArgs e)
        ScriptManager.RegisterStartupScript(this, GetType(), "AnyValue", "showAlert();", true);

Call JavaScript function with arguments.


 protected void btnPassValues_Click(object sender, EventArgs e)
        int a = 10;
        int b = 20;
        ScriptManager.RegisterStartupScript(this, GetType(), "AnyValue", "sumValues(" + a + "," + b + ");", true);

Final Output

call javascript function from asp net code behind and server side

We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

5 + 7 =
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2021 CodingFusion
75 Important SQL Server queries you should know