Archive for the ‘Uncategorized’ Category

September 1, 2008 0

How To Clear All Items From Cache

By J in Uncategorized

if (Cache.Count > 0)
{
string currentKey = string.Empty;
System.Collections.IDictionaryEnumerator cacheContents =
System.Web.HttpContext.Current.Cache.GetEnumerator();

Response.Write(string.Format(“Following {0} cache keys were cleared:”, Cache.Count));

while (cacheContents.MoveNext())
{
currentKey = cacheContents.Key.ToString();
Response.Write(currentKey + “”);
System.Web.HttpContext.Current.Cache.Remove(currentKey);
}
}
else
{
Response.Write(“Nothing to clear. Cache is empty.”);
}

Tags: ,

September 1, 2008 0

How To Load & Reference An Usercontrol From Code Behind

By J in Uncategorized

First lets create a sample user control called MyControl for demonstration purposes

public partial class _Controls_MyControl : System.Web.UI.UserControl
{
private string _myProperty;

public string MyProperty
{
get { return _myProperty; }
set { _myProperty [...]

Tags: ,

March 29, 2008 1

The Mysterious “Invalid Parameter Used” Error

By J in Uncategorized

Recently I was trying to write a little C# function for cropping images. I expected it to be a quick 5 minute task but I ended up spending a huge amount of time getting it to work correctly. I kept getting a very stubborn and mysterious error – “Invalid Parameter Used” – whenever I tried [...]

Tags: ,