This is a migrated thread and some comments may be shown as answers.
access scriptregistrar ondocumentready for extended telerik M.V.C custom control
1 Answer 68 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
David
Top achievements
Rank 1
David asked on 26 Jul 2010, 03:36 PM
Hi,

I'd like to call the ScriptRegistrar class from a custom control (which inherits from the ViewComponentBase class) to make it generate additional javasript when the control is rendered.

Any idea how to do it ?

I saw that to call additional scripts you use the ScriptFileNames property. Is there a similar way to add a javascript ?

Thanks for your help.

1 Answer, 1 is accepted

Sort by
0
Kyle Nunery
Top achievements
Rank 1
answered on 24 Aug 2010, 01:07 AM
1.  If you want to add js files then you add references to the files in the constructor for the custom control.

For example:
ScriptFileNames.AddRange(new[] { "telerik.common.js", "telerik.calendar.js", "telerik.datepicker.js" });

2. If you want to write out javascript you can do the following
        public override void WriteInitializationScript(System.IO.TextWriter writer)
        {
  // Typically you initialize the jquery plugin for your control here.
           ... add code here to write out any javascript you want...
}
Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Answers by
Kyle Nunery
Top achievements
Rank 1
Share this question
or