0

I need to add two relative Jquery files path in my master pages Head section. i try this for two file but just one of them calling in my "Head" section.i also use this cods in my master page Code Behind but it didn't work:

        protected void Page_PreRender(object sender, EventArgs e)
    {
        string jquery = ResolveClientUrl("~/JQuery/jquery-1.4.4.min.js");

        Page.ClientScript.RegisterClientScriptInclude("jquery", jquery);

        string jqueryShadow = ResolveClientUrl("~/JQuery/jquery.shadow.js");

        Page.ClientScript.RegisterClientScriptInclude("jqueryShadow", jqueryShadow);
    }

Also ,when i try this:

<script type="text/javascript" src="<%= Page.ResolveClientUrl("~/jquery.js") %>"></script>

i got same error with 1 link!

When i define both of Jquery files in my master page Head section directly, every things works for me!how can i inject my Jquery files(more than one!) with relative paths exactly on the Head section in Master Page?

Any idea?

Regards.

Community
  • 1
  • 1
Mohsen
  • 3
  • 2

1 Answers1

0

Have you tried the solution proposed (by @Bharath) on the link you provided?

var control = new HtmlGenericControl("script") ;
control.Attributes.Add("type", "text/javascript");
control.Attributes.Add("src", Page.ResolveClientUrl("~/JQuery/jquery-1.4.4.min.js")); 
this.Page.Header.Controls.Add(control);

You could put those statements on the Page_Load event of your MasterPage.

Regards,

ClayKaboom
  • 1,833
  • 1
  • 22
  • 42
  • Yes,I try this too,I write 2 block of these codes for include two Jjquery files, but just one of them included in "Head" section and another one ignored!(it was good if We can inject more than one file on "Head" section!) – Mohsen Jul 10 '11 at 18:21
  • Actually I tried it myself and it worked perfectly. I reinstantited the control var and readded, and my two added scripts worked like a charm. You have to notice that they are added in the same line, without linebreaks, when you inspect the generated HTML. – ClayKaboom Jul 11 '11 at 13:21
  • Thank you ClayKaboom,it was my fault. – Mohsen Jul 13 '11 at 18:17