Adding jquery include in DotNetNuke 4.8 skin does nothing

I am trying to incorporate JQuery into my DotNetNuke skin by adding these two lines of code at the top of my DNN wrapper:

<%                              
Page.ClientScript.RegisterClientScriptInclude("jquery", "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js")
Page.ClientScript.RegisterStartupScript(Me.GetType(), "jQueryNoConflict", "jQuery.noConflict()", True) 
%>

      

Unfortunately, when I go through the source on my page, I don't see the corresponding tag referencing jquery.min.js anywhere. Is DotNetNuke somehow cleaning up my requests to add a script to my pages here? What am I missing? I'm a bit of a newbie from DNN.

+1


source to share


3 answers


Sigh. The solution is to make sure you put it in the Page_Load () method and not the page rendering code itself. I guess I was using the page lifecycle too late to do what I wanted.



<script runat="server">
    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Page.ClientScript.RegisterClientScriptInclude("jquery", "http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js")
        Page.ClientScript.RegisterStartupScript(Me.GetType(), "jQueryNoConflict", "jQuery.noConflict();", True)
    End Sub
</script>

      

+1


source


What version of DNN are you using? DNN does not support including jQuery unless you are using DNN version 5. See here for details



0


source


You may run into problems doing it this way, depending on which version your code is targeting and whether your module will be used multiple times on the same page.

I have developed a set of methods to manage this more efficiently that are version independent, so you can make a single line call like this:

InjectjQueryLibary(this.Page, false, false, false); 

      

Boolean values ​​include jQuery UI, use uncompressed version, and include noConflict ().

A complete list of codes can be found in this blog post: Including jQuery in DotNetNuke module with independent version code

0


source







All Articles