Recommended hosting
Oct 27 2003

Designtime or not?

Posted by admin under ASP.NET articles

When developing server controls sometimes you want to know (in your code, I mean) whether it's designtime or not.

Things like caching and optimization might not be suitable to do when in designtime and the trick to know is checking the Context variable.

In practice, in the constructor, if Context is not null then we're running in design mode.



class YourServerControl 
	...
	private bool m_fIsDesignTime = true; ... 
	YourServerControl() 
	{ 
		if (Context != null) 
			m_fIsDesignTime = false; 
	}