JavaScript error “Return statement outside of function”
问题 Here is my code. I am calling a JavaScript function in the code after insert query fires. But I get the error "return statement outside of function". ClientScript.RegisterStartupScript(GetType(), "id", "return showPatientInfo('" + txtPatientID.Text + "');",true); function showPatientInfo(pid) { //alert(pid); RedirectToPage("Create_Order.aspx", "pid=" + pid); return false; } 回答1: I really wanted to rewrite your code as more idiomatic JavaScript. In the process, I found that