ASP.NET Ajax Controls and jQuery - What about IntelliSense?

Wednesday, November 26, 2008 by ASP.NET AJAX Team | Comments 10

  UPDATE: Please see this blog post for updated instructions on enabling IntelliSense in the Q1 '09 version.

We have recently announced that we are shipping jQuery with RadControls for ASP.NET Ajax. You can use this completely unmodified version of jQuery in your projects, as long as you have the RadControls assembly in your bin folder. This way you do not have to include jQuery and this can translate into 50kB less traffic.

You can enable IntelliSense, just like with the standalone jQuery, in VS2008 with a few simple steps.

1. Install the Visual Studio 2008 IntelliSense patch, if you have not already done so.

2. Download the jQuery IntelliSense documentation file and add it to your project. Rename it to jquery-telerik-vsdoc.js

3. Add a new file to your project, jquery-telerik.js, with the following content:

var jQuery = window.jQuery = window.$ = $telerik.$;

This will make jQuery accessible under its default alias - $.

Edit: Make sure that both jquery-telerik.js and jquery-telerik-vsdoc.js are in the same folder.

4. Add script references for jQuery and the jquery-telerik.js file in the ScriptManager on the page:

<asp:ScriptManager ID="ScriptManager" runat="server">
<Scripts>
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
<asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
<asp:ScriptReference Path="~/jquery-telerik.js" />
</Scripts>
</asp:ScriptManager>

 

And that is just about it. You can start using jQuery, as you normally would, with full IntelliSense support.

You will find a reference web site attached to this blog post.

Have a great day.

WebUI_jQuery.zip

10 Comments

  • chris 26 Nov 2008
    A few questions...

    Telerik client code access this embedded version of jQuery with $telerik.$ ?

    If we are using jQuery already there will be no conflict, other than its loaded twice into browser memory?

    If we do the above instructions, we don't have to ship our own jQuery, we can use the embedded one on any page with a script manager?

    Will Telerik normally ship with most recent top stable jQuery version?

    Thanks
  • Tsvetomir Tsonev 26 Nov 2008
    Very good questions, Chris. Thanks for asking.

    This is correct, we use the $telerik.$ alias to access jQuery internally.  It will not conflict with other jQuery instances on the page, but there will be some extra network traffic that can be avoided.

    Yes, you can use the embedded jQuery instead of the standalone version. We will update it to the latest official jQuery version on each RadControls release.

  • Eric 26 Nov 2008
    Another question:

    What are we doing with the file from step 2?

    2. Download the jQuery IntelliSense documentation file. Rename it to jquery-telerik-vsdoc.js
  • Tsvetomir Tsonev 27 Nov 2008
    Visual Studio will take care of it. You do not need to explicitly reference it anywhere. Just place it in the same folder as jquery-telerik.js and it will load the API reference from it.
  • Stas 03 Dec 2008
    accoridng to this
    http://weblogs.asp.net/scottgu/archive/2008/11/21/jquery-intellisense-in-vs-2008.aspx article



    should not include be

    <asp:ScriptReference Path="~/jquery-telerik-vsdoc.js" />

    instead of <asp:ScriptReference Path="~/jquery-telerik.js" />
  • ethan 23 Jan 2009
    I tried this using a telerik:RadScriptManger, and although the JQuery library is included and can be used, there is no Intellisense unless I use an asp:ScriptManger. Any reason why the RadScriptManager doesn't support intellisense?
  • Tsvetomir Tsonev 31 Mar 2009
    @Stas - I believe the reference is correct. The -vsdoc file will be included automatically by VS.

    @ethan - You're correct, IntelliSense doesn't seem to work with RadScriptManager. We'll look into this issue.
  • Matt 31 Jul 2009
    Did anyone solve the intellisense issue with this?

    Is there any newer documentation about the telerik/jquery integration I can look at, I am currently linking in a seperate jquery file to the telerik one + all works fine, and would like to save on the double download :)

    Thanks,
    Matt
  • Armin 04 Aug 2009
    And how can I reference the JQuery Library when Telerik.Web.UI.dll was dropped in GAC?
  • Stefan 24 Mar 2010
    You can review the latest support resources below concerning jQuery and RadControls for ASP.NET AJAX JavaScript IntelliSense, guys:

    http://www.telerik.com/help/aspnet-ajax/jquery-intellisense.html

    http://blogs.telerik.com/stefanrahnev/posts/10-03-01/radcontrols_for_asp_net_ajax_q1_2010_release_comes_with_native_net_4_builds_and_javascript_intellisense_in_vs_2008_2010.aspx

Add comment

  1. Formatting options
       
     
     
     
     
       
  2. (optional, emails won't be shown on public pages)
  3. (optional)