问题描述
我正在写一个包含自定义的控件(而不是用户控件)的自定义类库。
我已经要注册的页面上需要一些嵌入的JavaScript文件。
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.
现在,因为这是一个类库,我该如何检测是否使用ToolKitScriptManager或ScriptManager的?
Now since this is a class library, how do I detect whether or not to use a ToolKitScriptManager or ScriptManager?
Page.ClientScript是ClientScriptManager,但我会做,如果页面有新的ToolKitScriptManager?
Page.ClientScript is a ClientScriptManager, but would I do if the page has the new ToolKitScriptManager?
推荐答案
您可以通过调用静态确定你的控制正在被实例化的页面使用的ScriptManager
方法。如果返回空
,那么你可以假设,在页面利用(你的控件将只有你的网站中使用的基础上工作) ToolKitScriptManager
而非的ScriptManager
。
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
.
这篇关于从自定义控件访问ToolKitScriptManager /的ScriptManager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!