<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Client Side Web Development</title><link>http://forums.asp.net/130.aspx</link><description>Client-side programming discussions, including CSS, DHTML, JScript/Javascript, etc. &lt;a href="http://aspadvice.com/SignUp/list.aspx?l=18&amp;c=16" target="_blank"&gt;Email List&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2364595.aspx</link><pubDate>Sun, 18 May 2008 14:46:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2364595</guid><dc:creator>NC01</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2364595.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2364595</wfw:commentRss><description>&lt;p&gt;You would probably be better to be using Session objects instead of Cache objects in this instance. Session objects are tied to each user session while Cache objects are tied to the server and application itself. Session objects also get wiped after a designated time of no user input (which you can set yourself), so you would not have to really do anything to clear them.&lt;/p&gt;
&lt;p&gt;NC...&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2364381.aspx</link><pubDate>Sun, 18 May 2008 07:43:59 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2364381</guid><dc:creator>jchandra</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2364381.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2364381</wfw:commentRss><description>&lt;p&gt;Use HttpContext.Current.Cache instead since you won&amp;#39;t have access to instance members of Page object.&amp;nbsp; They are basically the same thing.&amp;nbsp; You will need to do this anyhow when you are trying to access Cache / Response / Request, etc. from your own webservice / class library, no different here.&lt;/p&gt;
&lt;p&gt;Be careful when doing this however.&amp;nbsp; Ran into a nasty bug last time when I tried to cache the Request object in my own helper library static object.&amp;nbsp; Blogged about it &lt;a class="" href="http://geeks.netindonesia.net/blogs/jimmy/archive/2008/04/25/it-s-time-to-play-spot-the-bug.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2364243.aspx</link><pubDate>Sun, 18 May 2008 01:09:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2364243</guid><dc:creator>rmdw</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2364243.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2364243</wfw:commentRss><description>&lt;p&gt;Thanks for your help, gents!&amp;nbsp; You got me pointed in the right direction and I&amp;#39;ve now solved it!&amp;nbsp; I wrote all about the solution on my &lt;a href="http://mwtech.blogspot.com/2008/05/using-ajax-page-methods-to-clear-cache.html" target="_blank"&gt;technical blog&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Robert&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2364200.aspx</link><pubDate>Sat, 17 May 2008 22:27:19 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2364200</guid><dc:creator>rmdw</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2364200.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2364200</wfw:commentRss><description>&lt;p&gt;Eric &amp;amp; Jimmy:&lt;/p&gt;&lt;p&gt;Thank you for your last comments.&amp;nbsp; Based on what you said I re-investigated PageMethods.&amp;nbsp; I&amp;#39;d done this before in some example code and tried to implement it here.&amp;nbsp; I got everything wired up correctly but then ran into &amp;quot;static vs. non-static&amp;quot; problem.&amp;nbsp; I don&amp;#39;t 100% understand it but essentially my belief is that PageMethods only work with static items whereas a web page and the cache is a non-static instantiated items.&amp;nbsp; The error I received when trying to clear a cache item was this:&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Error&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&amp;nbsp;&amp;nbsp;&amp;nbsp; An object reference is required for the nonstatic field, method, or property &amp;#39;System.Web.Caching.Cache.Remove(string)&amp;#39; &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Whether there&amp;#39;s a way around this, I do not know.&amp;nbsp; Perhaps someone will come across this posting who has been able to successfully tap into Web Page objects from PageMethods.&amp;nbsp; I haven&amp;#39;t.&lt;/p&gt;&lt;p&gt;Robert&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2363763.aspx</link><pubDate>Sat, 17 May 2008 11:18:25 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2363763</guid><dc:creator>jchandra</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2363763.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2363763</wfw:commentRss><description>&lt;p&gt;Like Alien51 said... Ajax could be your best buddy in this type of situation.&lt;/p&gt;
&lt;p&gt;One example (if you are using ASP.NET AJAX) to do this can be found &lt;a class="" href="http://pietschsoft.com/post/2008/04/Some-ASPNET-AJAX-Tips-and-Tricks.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2363507.aspx</link><pubDate>Sat, 17 May 2008 04:32:41 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2363507</guid><dc:creator>A1ien51</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2363507.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2363507</wfw:commentRss><description>The client and the server are separate. You can access the server directly. Only option would be to use Aajx or rely on session timeout. 

Eric</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2363500.aspx</link><pubDate>Sat, 17 May 2008 04:23:56 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2363500</guid><dc:creator>rmdw</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2363500.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2363500</wfw:commentRss><description>&lt;p&gt;Jimmy,&lt;/p&gt;&lt;p&gt;Thanks for your thoughts.&amp;nbsp; However, there&amp;#39;s a golden rule about now overusing ViewState, since everything you add to it will be attached to each &amp;amp; every page postback.&amp;nbsp; Storing DataTables (especially larger ones) in ViewState is not advisable.&lt;/p&gt;&lt;p&gt;I&amp;#39;m actually seeking to find out the syntax for accessing the Cache variables from the client.&lt;/p&gt;&lt;p&gt;Robert&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2363497.aspx</link><pubDate>Sat, 17 May 2008 04:14:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2363497</guid><dc:creator>jchandra</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2363497.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2363497</wfw:commentRss><description>&lt;p&gt;&amp;nbsp;Since I don&amp;#39;t know the entire design, I&amp;#39;d have to say that I&amp;#39;m not sure if this is the correct usage for Cache object.&amp;nbsp; You can use ViewState which is tightly coupled to the Page itself.&amp;nbsp; Cache should be used for things that stay longer than just a lifetime of a Page interaction I think.&lt;/p&gt;&lt;p&gt;In any case, you can choose to do a window.open in the window.onbeforeunload event to a cache cleaner utility page that will close itself once it&amp;#39;s done&lt;/p&gt;&lt;p&gt;or you can do something different like detecting the page url and it&amp;#39;s referrer to see if it&amp;#39;s coming from the same page on the destination page like so...&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;pre class="coloredcode"&gt;&lt;b id="1"&gt;1    &lt;/b&gt;    &lt;span class="kwd"&gt;if&lt;/span&gt; (Request.UrlReferrer != &lt;span class="kwd"&gt;null&lt;/span&gt;)
&lt;b id="2"&gt;2    &lt;/b&gt;        {
&lt;b id="3"&gt;3    &lt;/b&gt;            &lt;span class="kwd"&gt;if&lt;/span&gt; (Request.UrlReferrer.AbsolutePath != Request.Url.AbsolutePath)
&lt;b id="4"&gt;4    &lt;/b&gt;            {
&lt;b id="5"&gt;5    &lt;/b&gt;                Response.Write(&lt;span class="st"&gt;&amp;quot;I am coming from a different page, clear the cache&amp;quot;&lt;/span&gt;);
&lt;b id="6"&gt;6    &lt;/b&gt;            }
&lt;b id="7"&gt;7    &lt;/b&gt;            &lt;span class="kwd"&gt;else&lt;/span&gt;
&lt;b id="8"&gt;8    &lt;/b&gt;            {
&lt;b id="9"&gt;9    &lt;/b&gt;                Response.Write(&lt;span class="st"&gt;&amp;quot;I am coming from the same page, do nothing&amp;quot;&lt;/span&gt;);
&lt;b id="10"&gt;10   &lt;/b&gt;            }
&lt;b id="11"&gt;11   &lt;/b&gt;        }
&lt;/pre&gt;&amp;nbsp;&amp;nbsp;</description></item><item><title>Clearing Cache Objects Upon Page Unload</title><link>http://forums.asp.net/thread/2363405.aspx</link><pubDate>Sat, 17 May 2008 00:19:12 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:2363405</guid><dc:creator>rmdw</dc:creator><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/2363405.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=130&amp;PostID=2363405</wfw:commentRss><description>&lt;p&gt;I have a web page in which a lot of editing is done.&amp;nbsp; To accomplish what the user requires I implemented a number of cached objects, mostly DataTables.&amp;nbsp; It all works fine.&amp;nbsp; But . . . when the user leaves the page I&amp;#39;d like to clear them all. &lt;br /&gt;&lt;/p&gt;&lt;p&gt;In terms of leaving the page, I&amp;#39;ve implemented this Javascript functionality:&lt;/p&gt;&lt;p&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp; window.onbeforeunload = ConfirmExit;&lt;br /&gt;&lt;/i&gt;&lt;/p&gt;&lt;p&gt;&lt;i&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function ConfirmExit()&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; needToConfirmExit = Boolean(document.getElementById(&amp;#39;&amp;lt;%= needToSaveData.ClientID %&amp;gt;&amp;#39;).value);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (needToConfirmExit)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return &amp;quot;You have made changes that have not yet been saved back to the database.&amp;nbsp; If you leave now, all of those changes will be lost.&amp;nbsp; Are you absolutely sure you want to do this?&amp;quot;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&lt;/i&gt;&lt;br /&gt;So if the user does decide to leave the page then in the &amp;quot;onunload&amp;quot; event I could potentially clear the Cached objects.&amp;nbsp; But they&amp;#39;re ASP.Net objects so how to I access them from Javascript?&lt;/p&gt;&lt;p&gt;Robert W.&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>