0
我期待構建一個基本上提取ScriptManager的控件。我需要它看起來/感覺就像儘可能接近普通的ScriptManager一樣。原因是我們可以使用「#if not DEBUG」語句來動態加載CompositeScript中的.js文件以便發佈,但是也可以在我們的開發環境中保持簡單的調試。「自定義」ScriptManager控件?
這是我一直在玩到目前爲止(控制標記只含有一個空的ScriptManagerProxy):
Public Partial Class MyScriptManager
Inherits System.Web.UI.UserControl
Dim mlScripts As New List(Of ScriptReference)
Dim mlServices As New List(Of ServiceReference)
地區 「屬性」
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
端部區域
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
Region「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
端部區域
末級
看來,ScriptReferences沒有得到正確註冊。在DEBUG中,我收到了有關正在加載的多個腳本的錯誤,在RELEASE中,我得到了「sys未定義」(未加載Ajax庫)。我們使用ScriptReferenceProfiler來獲取所有正在加載的.js文件並手動添加它(也就是說,「MicrosoftAjax.js」被手動添加到ScriptManager的標記中)
任何幫助/方向感謝!