Microsoft Technology, .Net, BizTalk, Sharepoint & etc.

Liedong(Ken) Zheng, Senior SharePoint Developer at SIMPLOT

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)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>