This is a migrated thread and some comments may be shown as answers.

[Solved] ScriptRegister in HtmlHelperExtension

0 Answers 89 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Ron DeFreitas
Top achievements
Rank 2
Ron DeFreitas asked on 30 Apr 2010, 05:24 PM
Hi,

I have a field in my model that requires that I render an input box and a hidden field together, with a jQuery popup occurring on focus of the textbox which brings up a search window for the end-user to browse for another user, select them, and have the user's name populate in the textbox and their employee ID inserted into the hidden input.  This requires additional bindings occur during the $(document).ready event.  This all works properly when added manually and my custom popups all work fine, but I have a lot of code to copy every time I want to render this control.

Since my site is already making use of the Telerik MVC Extensions already and I reuse this particular control several times, I was hoping to write an HtmlExtension method to add the necessary boxes as well as adding the correct Script bindings using the ScriptRegistrar, as that is already on all of my pages...

Only problem is I can't for the life of me figure out how to use the ScriptRegistrar to add code to OnDocumentReady if I'm doing it in the context of an html helper as opposed to the context of a view.

Can anyone show a working example of using the ScriptRegistrar in a Html Helper Extension?
Tags
General Discussions
Asked by
Ron DeFreitas
Top achievements
Rank 2
Share this question
or