From server side to call javascript functions/Javascript at a particular point we use ClientScript.RegisterStartupScript .Ex:ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "Hi", "alert('The Field is mandatory');", true);And btn.Attributes.Add("onclick", "return sampleValidation)On click of button if we want to execute any javascript function from server side we use this.Both we use in code behind.