You may also do as below.
Page.ClientScript.RegisterStartupScript(this.GetType(),"Script Name" ,"script or JS Function ", true);
In case of when Ajax comes in picture, you must use
ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "Script Name", "Js Function.", true);