How to use jQuery in HTML page?

12 posts, 2 answers
  1. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 04 Nov 2011 Link to this post

    I have a ASPX web site with Telerik controls and jQuery but there is a HTML page without any aspx or Telerik controls (*.html).
    How to include jQuery in this HTML page?
  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 04 Nov 2011 Link to this post

    Hello Ildar,

    You could use JQuery in pure HTML page the same way you would in ASPX page. Check this link for more information.

    The first result is quire useful.

    All the best,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 04 Nov 2011 Link to this post

    Hi Andrey,

    I am already using this approach:
    <script src="jquery.js"></script>
    Is it that what you suggesting me?
    What I am trying to ask is how to get rid of second copy of jQuery?
    If I am using jQuery in aspx pages via Telerik, can I include it to html page without making additional copy of it?
    I think a some instance of jQuery exist on the server side.
    If I would known the address, I could link to that instance from html page.

    Thank you,
    Ildar
  5. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 07 Nov 2011 Link to this post

    Hi Jayesh,

    What do you mean?
    If you mean how to use jQuery then I know how to use.
    If you mean how to include jQuery then I am already using this way.
    Can you be a little bit more specific?

    Thank you,
    Ildar
  6. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 08 Nov 2011 Link to this post

    Hello Ildar,

    Please refer to this help article for additional information on how to use JQuery with RadControls.

    Greetings,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  7. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 08 Nov 2011 Link to this post

    Hi Andrey,

    Thanks. This article explains how to include jQuery to aspx pages.
    I am asking how to include jQuery to HTML pages without additional copy of jQuery.
    I am currently using in HTML page: /<script src="myfolder/jquery.js"></script>.
    But I have aspx pages too with jQuery included like:
    <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" />
    Therefore I have two version of jQuery.
    Can I have one?
    Is it possible?

    Thank you,
    Ildar
  8. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 09 Nov 2011 Link to this post

    Hello Ildar,

    As described in the article I have sent you in my last reply, you have several choices to use one and the same version of JQuery.

    1. Using a global variable

    <script type="text/javascript">
    window.$ = $telerik.$;
    </script>

    2. Using a self-calling anonymous function:
    <script type="text/javascript">
    (function ($) {
    $(document).ready(function () {
    alert("Hooray! The document is ready!");
    } ); })($telerik.$);
    </script>
    3. Using the $telerik.$ alias:
    <script type="text/javascript">
    $telerik.$(document).ready(function () {
    alert("Document is ready");
    });
    </script>
    4. Include a script reference to the Telerik.Web.UI.Common.jQueryInclude.js:

    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
    <Scripts>
     ......
    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
    </Scripts>
    </telerik:RadScriptManager>

    Which one of these you choose, it will work the same. Pick the one that is most convenient to you.

    I also attach a sample project which illustrates some of the aforementioned approaches.

    Kind regards,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  9. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 09 Nov 2011 Link to this post

    Hi Andrey,

    Where is HTML page in your sample project?
    As I outlined in all my posts I am asking about HTML page: file with html extension.
    For example manual.html.

    Thank you,
    Ildar
  10. Answer
    Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 11 Nov 2011 Link to this post

    Hi Ildar,

    There is no way to include an assembly reference in pure HTML page. The HTML pages are parsed from different ISAPI filters than the ASP.NET. So the HTML ISAPI filter could not parse ASP.NET assemblies in order to use the code logic in HTML page.

    However, you could check which version is used by RadScriptManager by executing the following command in your ASPX page:
    $().jquery;

    After this line of code has been executed, you will know what is the exact version of JQuery that the script manager uses and you will have the opportunity to include this version in your HTML page. Thus you will eliminate the multiple-versions problem across your project.

    Regards,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  11. Ildar
    Ildar avatar
    27 posts
    Member since:
    Apr 2009

    Posted 11 Nov 2011 Link to this post

    Hi Andrey,

    Thank you. This is the exactly answer what I need.
    Can you give me a tip how should I formulate a question next time to prevent long time discussion (1 week)?

    Thank you,
    Ildar
  12. Answer
    Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 14 Nov 2011 Link to this post

    Hello Ildar,

    A general rule when describing problem for which you are seeking answer from other person is to be as specific as you could when giving infromation. If you are sensing that something is unclear to the other person, it's best to try peraphrasing and to clear it out in order to prevent confusion.

    For example if you had started your ticket with something like the following:

    "Is there a way to include JQuery from RadControls assembly in a file with HTML extension? How to get the version of currently running instance of JQuery in RadControls?"

    would be a lot better. The last reply from you, when you mentioned the HTML file extension helped me to understand what you were talking about.

    However, you become good with technical communication after you get some experience on it. So, try following the aforementioned suggestions and with every next question you will get more familiar with it and it won't be a problem.


    Regards,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017