The trouble is, this field seems to be caching, because when visiting the page, it's remembering the value from a previous visit!
Setting httpcacheexpiration to 0:00:00 in the web.config fixes it, but ideally I'd just like the value to not be cached. I'm setting it in the code-behind, which I'd imagine is why this is happening.
Is there any way I can stop it from caching, or can I disable caching on that specific page template?
Thanks for any help!
I'm not sure it will work in your specific case, but try using the ASP.NET Substitution Web Server Control. http://msdn.microsoft.com/en-us/library/ms228108.aspx
I've investigated the substitution control, but as you said, it won't work with the problem I have. It uses a static method, and I'm actually trying to amend a hidden input field that's outside the control.
Does anybody else have any thoughts of how I can stop caching for a single hidden input field on a page short of setting httpcacheexpiration to 00:00:00?
You could add something like this to the Page_load of your template:
That will prevent all pages of that type to be cached.
I was looking on google for the last 2 hours to try and find something, and an article about setting httpcacheability to private for client-only caching in the web.config gave me a clue, but you just gave me the exact answer that I needed!
You are an absolute legend!
Another brief question then, if you would... Do I need to set the expiry of the cache to datetime.now for the private cacheability to take effect immediately, or is that just wiping out caching altogether, including client caching?
Thanks very much for your help so far, very much appreciated! :-)
Been awhile since I wrote that code so I had to do a little checking up and from I see HttpCachability.Private is default, and to be honest I do think you'd only need
Since that basically times out the chached version this instance no matter what HttpCacheability is set...
Maybe someone else here will verify that for us.