1

I'm busy building my first MVC app that uses the Telerik MVC components. Their docs specify that the ScriptRegistrar helper be called right at the bottom of a view, e.g. "at the end of the master page.". I assume this renders a script block that must only run when the page has loaded. I normally prefer to achieve this using jQuery, and keep all my script related stuff at the top of my master page, preferably in the <head> tag. Is there anything I can do to achieve this with the Telerik components and do away with the lone and forgotten helper call at the bottom of my master page?

2 Answers 2

1

The ScriptRegistrar has two main responsibilities:

  1. Render the JavaScript files needed by the UI Components
  2. Render the JavaScript initialization script for the UI Components

There is an explanation why the ScriptRegistrar needs to be last in the page. This is so because all UI components must register with it during rendering. Due the lack of any life-cycle (which is a good thing by the way) the ScriptRegistrar must appear (thus render) last. Otherwise the UI components would register too late - the ScriptRegistrar would have spit its output already.

To answer your question - yes you can omit the ScriptRegistrar and include the required JavaScript files by yourself. However you then need to manually initialize the UI components. The latter is possible but undocumented.

Sign up to request clarification or add additional context in comments.

Comments

0

The code generated by the ScriptRegister block is along the lines of

<script type="text/javascript" src="/asset.axd?id=dgAAAB-LCAAAAAAABADsvQdgHEmWJSYvbcp7f0r1StfgdKEIgGATJNiQQBDswYjN5pLsHWlHIymrKoHKZVZlXWYWQMztnbz33nvvvffee--997o7nU4n99__P1xmZAFs9s5K2smeIYCqyB8_fnwfPyJ-8Uezjx597xd_tPro0Uevp3WxapuPRh-d82dL-uynf9E6r6-3d8f743vjn8Z31UePdn7J93_J90cfTVtq0Obv2rs_nV1mDb9NDS7p072d3d0x_be7e58-mVIf9z69T7989Kit1_kv-X8CAAD__9hh2r92AAAA"></script>

which offer no clues as to what scripts are being then rendered. However, a quick peak with FireFox shows that that is loading jQuery. I'd suggest you start with the scriptregister block and then use Firebug to figure out what its calling, then try swapping it all out for a jQuery include (and other scripts if they get picked up).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.