Khi trang hiện tại vào giai đoạn PreRenderComplete, nó sẽ tự động gọi phương pháp Page_PreRenderComplete của điều khiển máy chủ hiện tại ScriptManager thể hiện trong Liệt kê 17-12. Như bạn có thể thấy, phương pháp này đầu tiên khởi tạo một bộ sưu tập Danh sách: | Chapter 17 Script and Extender Server Controls Page_PreRenderComplete When the current Page enters its PreRenderComplete phase it automatically invokes the Page_PreRenderComplete method of the current ScriptManager server control shown in Listing 17-12. As you can see this method first instantiates a List ScriptReference collection List ScriptReference list1 new List ScriptReference Next it invokes another method named CollectScripts passing in the List ScriptReference collection to have this method to populate this collection with the list of ScriptReference objects that reference JavaScript files list1 Then it iterates through the ScriptReference objects in the List ScriptReference collection and performs these two tasks for each enumerated ScriptReference object. First it instantiates a ScriptReferenceEventArgs instance passing in a reference to the enumerated ScriptReference object. As you ll see later the ScriptReferenceEventArgs is the event data class associated with an event named ResolveScriptReference. Next it invokes a method named OnResolveScriptReference passing in the ScriptReferenceEventArgs object to raise the ResolveScriptReference event. As you ll see later this enables the page developer to register an event handler for this event whereby he or she can use custom code to resolve the reference to the JavaScript file specified by the enumerated ScriptReference object. foreach ScriptReference reference3 in list1 args new ScriptReferenceEventArgs reference3 args Next the Page_PreRenderComplete method iterates through the ScriptReference objects in the List ScriptReference collection once more and takes these steps for each enumerated ScriptReference object. It checks whether the LoadScriptsBeforeUI property is set to true. If so this indicates that the page developer has requested the referenced JavaScript files to be loaded before the UI is loaded. As a result the Page_PreRenderComplete method .