The next version of Microsoft’s Internet Explorer looks like it will be the most ‘compliant’ yet, with full CSS 2.1 even partial CSS 3 support promised in IE8.
But the general public don’t really care about Acid2 and the like. What they want are USPs such as Visual Search, which actually looks quite smart.
A work colleague of mine made me aware of the rather useful CacheDependency class the other day and I’ve been implementing this in various places since. It is useful when you wish to store some data in an ASP.NET web application’s Cache but wish that data to remain in the Cache according to an external influence rather than a time frame.
For example, if you had a typed DataSet and stored some XML that conformed to its Schema on disk, you could use CacheDependency to store the data in the Cache until such time as the physical file is modified.
public static MyDataSet GetDataSet(string path)
{
if (HttpContext.Current.Cache["MyDataSet" + path] == null)
{
MyDataSet ds = new MyDataSet();
try
{
ds.ReadXml(HttpContext.Current.Server.MapPath(path));
}
catch (Exception ex)
{
throw new MyException(string.Format("Unable to load file '{0}' as a MyDataSet", path), ex);
}
CacheDependency dependency = new CacheDependency(HttpContext.Current.Server.MapPath(path));
HttpContext.Current.Cache.Insert("MyDataSet" + path, ds, dependency);
}
return HttpContext.Current.Cache["MyDataSet" + path] as MyDataSet;
}
In the example above, when the file located at path is modified, the Cache will be cleared due to the dependency. When GetDataSet() is next called, the latest version of the file will be loaded into the Cache instead.
Don’t you hate it when you need to do something so basic that you just can’t fathom the best way to achieve it? No? OK, it’s just me then.
What if you’ve just got a basic HTML anchor that you want to run some JavaScript event off, such as onclick, but don’t want the browser to go to the ‘top’ of the page when actioned? The following will shift to the top of the page when clicked:
<a href="#" onclick="alert('Clicked');">Click me</a>
but the following will not, as expected:
<a href="javascript:void(0);" onclick="alert('Clicked');">Click me</a>
Simple when you know how!
Hello and welcome to my new technical blog!
This is where I’ll be posting various useful findings that I would like to share with the world during my time as a web developer.
“Why have you waited 12 years?” I hear you ask. I cannot answer that. No excuses.