Register JavaScripts in 2 ways
Posted by ken zheng on September 19, 2008
You can register your JavaScript in server side by 2 ways
' The very first control added to the form must be the AJAX script manager.
Dim cl As ClientScriptManager = Me.ClientScript
Dim cstype As Type = Me.GetType()
cl.RegisterClientScriptInclude(cstype, "DefaultScript", ResolveClientUrl("~/JScript Files/Test.js"))
myScriptManager = New ScriptManager
myScriptManager.ID = "__PageScriptManager"
myScriptManager.EnablePageMethods = True
myScriptManager.RegisterStartupScript(Me, GetType(Page), "StartManualTearDownScript", "manualTearDown.init();", True)
If Me.PageAccess = PageAccessType.SecurePage Then
Dim ref As New System.Web.UI.ScriptReference("JScript Files/Secure.js")
myScriptManager.Scripts.Add(ref)
End If
myScriptManager.AsyncPostBackTimeout = WebConfigurationHelper.AsyncPostBackTimeout
myHtmlForm.Controls.Add(myScriptManager)