You should use ClientScript.RegisterStartupScript to be able to run scripts on the master page whithout having any problems on runtime.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", "<Script for=" + "window" + " " + "event=" + "onload" + " " + "language=" + "jscript" + ">" + "if(window.form.txtSomeTextBox.value == ""){ window.form.txtSomeTextBox.focus();}</Script>")
'// To test it, just comment the above line and uncomment the line bellow.
'// if the alert window is shown then it's working just fine!
'// I've tested and works great!
'ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", "<Script for=" + "window" + " " + "event=" + "onload" + " " + "language=" + "jscript" + ">" + "alert('works!');</Script>")
End Sub
Enter your message below
Sign in or Join us (it's free).