Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing ToolKitScriptManager/ScriptManager from custom control

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?

like image 408
Matt Avatar asked May 16 '26 23:05

Matt


1 Answers

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.

like image 131
Rob Avatar answered May 19 '26 14:05

Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!