How to Inject JavaScript from Global Event Handler

Patrick Taylor asked on December 17, 2018 18:44

What is the best way to inject a JavaScript reference to all the Kentico 11 admin UI pages from a Global Event Handler? I've tried accessing the ClientScriptManager from the sender object, but I'm seeing a lot of redundancy and potential null reference exceptions that I'd prefer to avoid. Could I perhaps inject an HTML script tag from my code-only custom module where the global event handler is defined? I'm open to any ideas on how to best accomplish this customization.

Correct Answer

Peter Mogilnitski answered on December 18, 2018 18:33

Well in this case you can go directly to \CMS\Admin\CMSAdministration.aspx.cs and register your script using ScriptHelper on OnPreRender event.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Peter Mogilnitski answered on December 17, 2018 20:38 (last edited on December 17, 2018 20:39)

Technically all Kentico modules are using the same set of page templates if i am not mistaken :

  • New / Edit object
  • Object listing
  • Object tree

You can cerate UI web part for javascript (there is none) or directly add to the layout or add it as text.

0 votesVote for this answer Mark as a Correct answer

Patrick Taylor answered on December 18, 2018 15:01

@Peter, the issue there is that I want this JavaScript to run on every Kentico admin UI page. That includes the dashboard as well as any modules in the UI. I don't believe the Kentico Dashboard uses any of those page templates.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.