Monday, January 3, 2011

URL Rewritting Resolve URL in my external CSS and JavaScript Files

I have applied url rewritting from scott: URL Rewriting Tutorial to make my url's SEO friendly.
However, my css and javascript files are created internally (w/ in the page itself). When i tried separating my css and .js files, I usually encountered javascript errors such as:

1. GetCustomerDetail is undefined [based from Mozilla Firebug]
2. Microsoft JS runtime error: object required [Internet explorer]

I tried googling for hours about object required and have'nt found an answer. As i read again scott's article, the last paragraph was a hint regarding how to resolve CSS and image external links.

The solution I came up with was using Control.ResolveUrl() so that my external javascript and css files will work.
1:  src='<%= Page.ResolveUrl("yourjsfile")%>'  
2:  href='<%= Page.ResolveUrl("yourcssfile")%>'  
A good resource, but haven't tested yet. Westwind Tutorial
FROM MSDN: MSDN

0 comments:

Post a Comment