开发者

Controlling the order of <script> tags created by ScriptManager

I am successfully including a javascript resource by calling ScriptManager.RegisterClientScriptResource at the end of OnPreRender in my custom control. However, the resulting script tag is being included before the automatically included script tags that define thing开发者_如何学Pythons like Type and Sys which my script depends on. I thought they were defined in the order that they are included but I can't include my script any later then I am. How can I control the order in which the script tags are included?


Your parent page that contains the custom control must have ScriptManager and make sure the custom control you add is placed after the ScriptManager Tag. Sometimes its best just to place the ScriptManager tag in the MasterPage.

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
.......
<uc:YourControl ID= "YC" runat = "server" />


Try to do this on OnLoad, not on OnPreRender

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜