Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

We can add into references to JS or CSS files from HTML:

<SCRIPT TYPE="text/JavaScript " SRC="FileName.js?v=<%=AssemblyVersionNumber()%>">

The attribute does nothing other than trick the browser into thinking that the .js file must be retrieved from server for new version instead of cached .

You can write your own AssemblyVersionNumber() function or use my function from My SystemHelper class. like the following:

SystemHelper.GetAssemblyVersion(Assembly.GetExecutingAssembly())

Idea from http://www.thescripts.com/forum/thread165240.html

Note that it could be  problems, if head element has runat="server" attribute.

Also consider to reduce number of CSS and JS files.

Posted on Friday, October 19, 2007 11:50 AM ASP.NET | Back to top


Comments on this post: Ensure that JavaScript files or CSS files are refreshed for each new version

# re: Ensure that JavaScript files or CSS files are refreshed for each new version
Requesting Gravatar...
In the .aspx file i am unable to get AssemblyVersionNumber() from the Intellisense. Can you please help me how should i get that?

Thank you so much...!
-Ashwath
Left by Ashwath on Nov 02, 2007 11:12 PM

# re: Ensure that JavaScript files or CSS files are refreshed for each new version
Requesting Gravatar...
I've updated the post to add reference to http://geekswithblogs.net/mnf/articles/87855.aspx#GetAssemblyVersion
Left by Michael Freidgeim on Nov 03, 2007 12:15 AM

Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net