Why do I lose my javascript from the browser cache after a full page postback?
Posted
by burak ozdogan
on Stack Overflow
See other posts from Stack Overflow
or by burak ozdogan
Published on 2010-04-22T09:54:47Z
Indexed on
2010/04/22
10:03 UTC
Read the original article
Hit count: 585
JavaScript
|ASP.NET
Hi,
I have an external javascript file which I include to my page on the code behind (as seen below).
My problem is, when I my page makes a postback (not partial one), I check the loaded scripts by using FireBug, and I cannot see the javascript file in the list after the post back. I asusmed once it is included to page on the first load, browser will be caching it so that I do not need to re-include it.
What am I doing wrong?
The way I include the script is here:
protected override void OnInit(EventArgs e)
{
if (this.Page.IsPostBack==false)
{
if (this.Page.ClientScript.IsClientScriptIncludeRegistered("ctlPalletDetail")==false)
{
string guidParamToHackBrowserCaching = System.Guid.NewGuid().ToString();
this.Page.ClientScript.RegisterClientScriptInclude("ctlPalletDetail", ResolveUrl(String.Format("~/clientScripts/ctlLtlRequestDetail.js?par={0}",guidParamToHackBrowserCaching)));
}
}
base.OnInit(e);
}
© Stack Overflow or respective owner