I’m having a pretty nasty problem with the VS 2008 Designer in SP1. Apparently from time to time the Web designer decides it doesn’t like to assign simple property values for controls anymore and starts displaying errors for individual controls on the form.
Here’s what this looks like in the designer:
Designer errors can happen for lots of reasons, but since I installed SP1 I’ve been seeing the above quite frequently with my own custom controls as well with several third party controls.
What’s odd about the error above is that the control works at first. Stays on the page everything is editable in the designer, property sheet and it renders fine on the page. Then all of a sudden it fails with a property assignment error like above. The property will vary – it’s always the first custom property, so if shuffle a different custom property to be first that property will show up as the error property.
If I remove all custom properties then the control renders again.
In this case the Draggable property is just a plain property with a private field backing.
/// <summary>
/// Determines whether this control is draggable
/// </summary>
[Description("Determines whether this control is draggable")]
[DefaultValue("true"), Category("Dragging")]
public bool Draggable
{
get { return _Draggable; }
set { _Draggable = value; }
}
private bool _Draggable = true;
Nothing that could possibly go wrong in assignment. There’s some OnInit() code but it’s bracketed out for designmode:
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
if (!this.DesignMode)
{
this.ScriptProxy = ClientScriptProxy.Current;
// *** Use ScriptProxy to load jQuery and ww.Jquery
ScriptProxy.LoadControlScript(this, this.jQueryScriptLocation, ControlResources.JQUERY_SCRIPT_RESOURCE, ScriptRenderModes.HeaderTop);
ScriptProxy.LoadControlScript(this, this.ScriptLocation, ControlResources.WWJQUERY_SCRIPT_RESOURCE);
}
}
This is important to avoid code that might not work at designtime because the HttpContext object doesn’t exist.
Anyway, the control works fine. In fact in the screen shot above, there there are two of the same controls on the page – the panel above is another instance of the same control type.
As I mentioned I’ve also seen similar failures with Telerik and DevExpress controls, so I don’t think it’s something that’s wrong with my controls or if it is it’s a common issue.
Unfortunately the fix for this is to restart Visual Studio. That’s right – I can’t shut down the page and re-open it; I still get the error in that case. But if I close down Visual Studio and re-open it everything is hunky dory again – until next time this sort of failure pops up again on a different control or page. Oddly if I drop another control instance on the same page that will work just fine. Freaky.
I don’t use the designer very much – typically just to drop controls onto page and in some cases to use the property editor, but even so I see this sort of error several times almost every day.
So, has anybody else seen this sort of behavior in the Web Designer? I’ve been looking around and pinging a few folks, but so far it seems this is not a common problem. Would love to hear some feedback to see if others are seeing the same, or even better if somebody has figured out a workaround or at least the cause for the issue.
Other Posts you might also like