I am writing an ASP Web Application. it uses Master Pages and also uses XSLT stylesheets to transform XML data. Some of my pages use Jquery .JS scripts to add functionality. I have one .css that applies to all pages on the site, but each page also has its
own .css stylesheet to format various sections of the page. Most of the content in these pages are created within the .XSLT stylesheets.
Am having a problem with knowing where to include each of the supporting files for these pages to make them accessible to all of the parts that make up each page. For example, Page1.aspx requires page1.css for formatting the general page outline, but page1.xslt
also uses page1.css. Including page1.css in the <head> of page1.aspx doesn't seem to make the css available to page1.xslt - so I have to include page1.css in both the .aspx and the .xslt.
Another thing I can't figure out is why I can't just include jquery.js inside the <head> of my Master page one time and it be available for all of the code that makes up each page. Instead, I'm having to include jquery.js in the <head> of the Master page,
in the <head> of each aspx page that uses the Master page, and also inside each XSLT stylesheet that is included in each aspx page. It seems redundant, to say the least, but each part of these pages make use of Jquery to some degree.
Today I wanted to include yet another .js script inside one of my XSLT stylesheets, but I couldn't get it to work. I started wondering about several possibilities, none of my ideas effected the problem... Then I realized that my .XSLT files included <html><head></head><body></body></html>
tags. I began to wonder if this was even legal, despite that it has been working. So I did some research by googling and found several articles stating that multiple <html>, <head> and <body> tags within a single page are not legal. So I removed them. This
broke all of my .js scripts in the .XSLT files.
I don't have much of a choice on putting some of the .js inline in my .XSLT files since the parameters for these scripts change dynamically with the contents of the XML data.
So, my questions are these:
Is it common practice to include a .css stylesheet in the <head> of an ASPX page and also include it in the .XSLT stylesheet that's included in the .ASPX? Is there a place/syntax to include a .css that will make it recognized by an entire page's contents?
Do I really need to include jquery.js in the .ASPX as well as the .XSLT to make it available to both parts of the page? Again, is there a place/syntax to include Jquery.js in one place that will make it available to the entire page? Why can't I just include
it one time in the <head> of the Master page? Seems like that should take care of every page, but it doesn't.
Lastly, can anyone confirm whether multiple <html>, <head> and <body> tags are legal in a single ASPX page? If not, how to I include Jquery.js in my .XSLT stylesheets if there is no <head></head> to place it in?
Hope this isn't too complicated to explain to me, I'm really stuck right now since I just don't know the correct way to handle this and it seems to make a huge difference where I include these files.
rwkiii
Member
55 Points
43 Posts
How/where to include .js and .css files?
Apr 10, 2012 08:48 PM|LINK
I am writing an ASP Web Application. it uses Master Pages and also uses XSLT stylesheets to transform XML data. Some of my pages use Jquery .JS scripts to add functionality. I have one .css that applies to all pages on the site, but each page also has its own .css stylesheet to format various sections of the page. Most of the content in these pages are created within the .XSLT stylesheets.
Am having a problem with knowing where to include each of the supporting files for these pages to make them accessible to all of the parts that make up each page. For example, Page1.aspx requires page1.css for formatting the general page outline, but page1.xslt also uses page1.css. Including page1.css in the <head> of page1.aspx doesn't seem to make the css available to page1.xslt - so I have to include page1.css in both the .aspx and the .xslt.
Another thing I can't figure out is why I can't just include jquery.js inside the <head> of my Master page one time and it be available for all of the code that makes up each page. Instead, I'm having to include jquery.js in the <head> of the Master page, in the <head> of each aspx page that uses the Master page, and also inside each XSLT stylesheet that is included in each aspx page. It seems redundant, to say the least, but each part of these pages make use of Jquery to some degree.
Today I wanted to include yet another .js script inside one of my XSLT stylesheets, but I couldn't get it to work. I started wondering about several possibilities, none of my ideas effected the problem... Then I realized that my .XSLT files included <html><head></head><body></body></html> tags. I began to wonder if this was even legal, despite that it has been working. So I did some research by googling and found several articles stating that multiple <html>, <head> and <body> tags within a single page are not legal. So I removed them. This broke all of my .js scripts in the .XSLT files.
I don't have much of a choice on putting some of the .js inline in my .XSLT files since the parameters for these scripts change dynamically with the contents of the XML data.
So, my questions are these:
Is it common practice to include a .css stylesheet in the <head> of an ASPX page and also include it in the .XSLT stylesheet that's included in the .ASPX? Is there a place/syntax to include a .css that will make it recognized by an entire page's contents?
Do I really need to include jquery.js in the .ASPX as well as the .XSLT to make it available to both parts of the page? Again, is there a place/syntax to include Jquery.js in one place that will make it available to the entire page? Why can't I just include it one time in the <head> of the Master page? Seems like that should take care of every page, but it doesn't.
Lastly, can anyone confirm whether multiple <html>, <head> and <body> tags are legal in a single ASPX page? If not, how to I include Jquery.js in my .XSLT stylesheets if there is no <head></head> to place it in?
Hope this isn't too complicated to explain to me, I'm really stuck right now since I just don't know the correct way to handle this and it seems to make a huge difference where I include these files.
Thx!