控制
我通过在自定义控件中的 OnPreRender
末尾调用 ScriptManager.RegisterClientScriptResource
成功包含了 javascript 资源。但是,生成的脚本标记包含在自动包含的脚本标记之前,这些脚本标记定义了我的脚本所依赖的 Type
和 Sys
等内容。我认为它们是按照包含的顺序定义的,但我不能稍后包含我的脚本。如何控制脚本标签的包含顺序?
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 things 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
包含自定义控件的父页面必须具有 ScriptManager,并确保您添加的自定义控件放置在 ScriptManager 标记之后。有时最好将 ScriptManager 标记放置在 MasterPage 中。
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.
尝试在
OnLoad
上执行此操作,而不是在OnPreRender
上执行此操作Try to do this on
OnLoad
, not onOnPreRender