How to use Javascript using Server-side scripting

This article is interesting for those who loves to use javascript, but with little server postbacks. I had some times issues related to validation or client redirection or other sorts. So i got this solution and i would like to share it with you.
Here I am presenting a scenario. I have a button, and OnClick of this button, i want to call java script function.

On Server Side (.aspx.cs)
Write this code under Button_Click event or in any server event.

ClientScript.RegisterStartupScript(this.GetType(), "key", "SubmitConfirm();",true);

You can also pass server control, properties to the "SubmitConfirm();" function.

On Client Side (.aspx)
write within javascript tag

function SubmitConfirm()


  alert('Form Submitted and Information Sent to');



kick it on

Published Saturday, June 28, 2008 9:24 PM by NavaidAkhtar


# re: How to use Javascript using Server-side scripting

Sunday, December 23, 2012 7:49 PM by Hopson

Hi there, just became aware of your blog through Google,

and found that it’s truly informative. I am gonna

watch out for brussels. I will be grateful whenever you continue this in future.

Numerous people will be benefited from your writing. Cheers!

# re: How to use Javascript using Server-side scripting

Tuesday, January 15, 2013 4:29 PM by Shockley

It's truly a nice and helpful piece of info. I’m satisfied someone to shared this helpful information with us. Please stay us present along the lines of this. Thanks for sharing.

Leave a Comment