Tuesday, September 9, 2008

Determine if Your Web Part is in Design Mode

Credit for this goes to David Bond and Rick Phillips, I’m just posting because David mentioned it and I think it’s a helpful tip.  This is being used in PTS web part projects as well as the new RHACS solution.  I think David made a great point in the meeting Tuesday by stating if you’re in design mode, there’s probably no reason you need to be pinging a database or web service, etc.

Here’s the code:

WebPartManager wpm = WebPartManager.GetCurrentWebPartManager(this.Page);
webPartIsInDesignMode = wpm.DisplayMode.AllowPageDesign;

No comments: