开发者

"Custom" ScriptManager control?

I'm looking to build a control that essentially abstracts a ScriptManager. I need it to look/feel just like as close to a regular ScriptManager as possible. The reason for this is so we can use an "#if not DEBUG" statement to dynamically load the .js files in CompositeScript for release, but also maintain easy debugging in our dev environment.

Here is what I've been playing with so far(The control markup contains nothing but an empty ScriptManagerProxy):

Public Partial Class MyScriptManager
Inherits System.Web.UI.UserControl

Dim mlScripts As New List(Of ScriptReference)
Dim mlServices As New List(Of ServiceReference)

Region "Properties"

Public Property Scripts() As List(Of ScriptReference)
    Get
        Return mlScripts
    End Get
    Set(ByVal value As List(Of ScriptReference))
        mlScripts = value
    End Set
End Property

Public Property Services() As List(Of ServiceReference)
    Get
        Return mlServices
    End Get
    Set(ByVal value As List(Of ServiceReference))
        mlServices = value
    End Set
End Property

End Region

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

    #If DEBUG Then
       LoadNonComposite()
    #Else
       LoadComposite()
    #End If

    For Each scr As ServiceReference In mlServices
        smScriptManagerProxy1.Services.Add(scr)
    Next

End Sub

Re开发者_如何转开发gion "Helper Methods"

Private Sub LoadComposite()
    For Each sr As ScriptReference In mlScripts
        smScriptManagerProxy1.CompositeScript.Scripts.Add(sr)
    Next
End Sub

Private Sub LoadNonComposite()
    For Each sr As ScriptReference In mlScripts
        smScriptManagerProxy1.Scripts.Add(sr)
    Next
End Sub

End Region

End Class

It appears that the ScriptReferences are not getting registered correctly. In DEBUG, I get errors about multiple scripts being loaded, and in RELEASE, I get "sys not defined"(Ajax library not being loaded). We use ScriptReferenceProfiler to get all the .js being loaded and add it manually(aka, "MicrosoftAjax.js" is manually added to the ScriptManager in markup)

Any help/direction is appreciated!


Sorry guys, I figured it out. I was using copy and pasted .js references from a while ago and they had changed since. Thus causing the issue.

The above code works, if anyone is interested in an easy performance boost without sacrificing ease of development.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜