Accessing ToolKitScriptManager/ScriptManager from custom control

不羁的心 提交于 2019-12-10 22:08:34

问题


I'm writing a custom class library that contains custom controls (not user controls). I have some embedded javascript files that need to be registered on the page.

Now since this is a class library, how do I detect whether or not to use a ToolKitScriptManager or ScriptManager?

Page.ClientScript is a ClientScriptManager, but would I do if the page has the new ToolKitScriptManager?


回答1:


You can determine if the page your control is being instantiated in is using a ScriptManager by calling the static ScriptManager.GetCurrent() method. If this returns null then you could assume that (working on the basis that your controls will only be used within your websites), the page is utilising a ToolKitScriptManager rather than a ScriptManager.



来源:https://stackoverflow.com/questions/3432360/accessing-toolkitscriptmanager-scriptmanager-from-custom-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!