Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005)http://forums.asp.net/t/1056458.aspx/1?Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Fri, 05 Jan 2007 19:14:55 -050010564581504382http://forums.asp.net/p/1056458/1504382.aspx/1?Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>I'm running into strange problems all around after converting my .NET 1.1 code&nbsp;in VC# 2003 to .NET 2.0 in VC# 2005.</p> <p>I have a custom control based off of WebControl.&nbsp; The tag is defined as &quot;cc:CustomControl&quot;, since this control rendered as an HTC component on the client end.&nbsp; I have a custom designer&nbsp;based on ControlDesigner now (didn't work without it either) that simply outputs an HTML table.</p> <p>&nbsp;This control does not behave like other controls that are built the same way and I can't figure out why.&nbsp; When I try to click on this control on a web form it doesn't select like other controls.&nbsp; When I try to grab this control and move it to a different spot, the whole web form behaves like a drop target as if I were trying to move the control into a region, and keeps it at the top left corner.&nbsp; At the bottom left of the IDE, the status bar displays &quot;Left: auto Top: auto&quot;.&nbsp; Other controls that move fine display &quot;Left: ###px Top ###px&quot; as they should.&nbsp; I don't know why or how to regulate that.</p> <p>Does anyone have an idea of what I'm doing wrong?&nbsp; This control worked fine in VC# 2003.</p> 2006-12-20T23:37:45-05:001505898http://forums.asp.net/p/1056458/1505898.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) &nbsp;Here's a mock up of what I'm doing that exhibits the same problem.&nbsp; Anyone?&nbsp; I'm stumped.<pre class="prettyprint">public class ContextMenuTestDesigner : System.Web.UI.Design.ControlDesigner { public ContextMenuTestDesigner( ) { } public override bool AllowResize { get { return false; } } public override string GetDesignTimeHtml( ) { Table tbl = new Table( ); tbl.CellPadding = 1; tbl.CellSpacing = 1; tbl.Style.Add( HtmlTextWriterStyle.BackgroundColor, &quot;menu&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderCollapse, &quot;collapse&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderStyle, &quot;outset&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderWidth, &quot;2px&quot; ); tbl.Style.Add( HtmlTextWriterStyle.Display, &quot;block&quot; ); tbl.Style.Add( HtmlTextWriterStyle.FontSize, &quot;8pt&quot; ); tbl.Style.Add( HtmlTextWriterStyle.FontFamily, &quot;Microsoft Sans Serif, Verdana, Arial, Helvetica&quot; ); tbl.Style.Add( HtmlTextWriterStyle.Padding, &quot;1px&quot; ); for( int i = 1; i &lt;= 10; i&#43;&#43; ) { TableRow tr = new TableRow( ); TableCell td = new TableCell( ); if( (i % 3) != 0 ) // 2 items, then a separator { WebControl wc = new WebControl( HtmlTextWriterTag.Div ); if( i == 2 ) // hilight 2nd item { wc.Style.Add( HtmlTextWriterStyle.BackgroundColor, &quot;highlight&quot; ); wc.Style.Add( HtmlTextWriterStyle.Color, &quot;highlighttext&quot; ); } else { // alternate disabled look wc.Style.Add( HtmlTextWriterStyle.Color, ((i % 2) != 0) ? &quot;black&quot; : &quot;inactivecaptiontext&quot; ); } wc.Style.Add( HtmlTextWriterStyle.Cursor, &quot;default&quot; ); wc.Style.Add( HtmlTextWriterStyle.Overflow, &quot;visible&quot; ); wc.Style.Add( HtmlTextWriterStyle.Padding, &quot;2px 18px 2px 14px&quot; ); wc.Style.Add( HtmlTextWriterStyle.Width, &quot;100%&quot; ); LiteralControl lc = new LiteralControl( ); lc.Text = &quot;Menu Item &quot; &#43; i.ToString( ); wc.Controls.Add( lc ); td.Controls.Add( wc ); } else { td.Height = Unit.Pixel( 0 ); td.Style.Add( &quot;border-top&quot;, &quot;1px solid threedshadow&quot; ); td.Style.Add( &quot;border-bottom&quot;, &quot;1px solid threedhighlight&quot; ); } tr.Cells.Add( td ); tbl.Rows.Add( tr ); } StringWriter sw = new StringWriter( ); HtmlTextWriter htw = new HtmlTextWriter( sw ); tbl.RenderControl( htw ); return sw.ToString( ); } } [ Designer( typeof( ContextMenuTestDesigner ) ), ToolboxData( &quot;&amp;lt;{0}:ContextMenuTest runat=\&quot;server\&quot;&amp;gt;&amp;lt;/{0}:ContextMenuTest&amp;gt;&quot; ) ] public class ContextMenuTest : System.Web.UI.WebControls.WebControl { public ContextMenuTest( ) : this( String.Empty ) { } public ContextMenuTest( string id ) : base( HtmlTextWriterTag.Div ) // base( &quot;c:ContextMenuTest&quot; ) { this.ID = id; } }</pre>&nbsp; 2006-12-21T23:18:27-05:001505901http://forums.asp.net/p/1056458/1505901.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>The attributes for ContextMenuTest got escaped by the forum software, should be:</p> <p>[<br> Designer( <span class="kwd"><font color="#0000ff">typeof</font></span>( ContextMenuTestDesigner ) ),<br> ToolboxData( <span class="st"><font color="#ff0000">&quot;&lt;{0}:ContextMenuTest runat=\&quot;</font></span>server\<span class="st"><font color="#ff0000">&quot;&gt;&lt;/{0}:ContextMenuTest&gt;&quot;</font></span> )<br> ]<br> </p> 2006-12-21T23:21:26-05:001506309http://forums.asp.net/p/1056458/1506309.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <span class="455433008-22122006"><span class="556100108-22122006"><font color="#008080">&nbsp;</font><span class="455433008-22122006"><span class="556100108-22122006"><font color="#008080">That's because your&nbsp; <font size="2">ContextMenuTestDesigner class is full of errors.</font></font></span></span> <p><span class="455433008-22122006"><span class="556100108-22122006"><font color="#008080"><font color="#008080" size="2">Delete <br> <font color="#008080" size="2">Designer</font><font color="#000000" size="2">(</font><font color="#0000ff" size="2">typeof</font><font color="#000000" size="2">(</font><font color="#008080" size="2">ContextMenuTestDesigner</font><font size="2"><font color="#000000">)),<br> before <br> <font color="#0000ff" size="2">public</font><font size="2"> </font><font color="#0000ff" size="2">class</font><font size="2"> </font><font color="#008080" size="2">ContextMenuTest</font><font size="2"> : System.Web.UI.WebControls.</font><font color="#008080" size="2">WebControl<br> </font><font size="2">{<br> and everything works OK</font></font></font></font></font></span></span></p> </span></span> 2006-12-22T09:01:59-05:001506398http://forums.asp.net/p/1056458/1506398.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <strong>Why not to use (just Drag&amp;Drop from ToolBox) ready Menu or TreeView?<br> </strong><br> <span class="556100108-22122006">I do not quite understand your logic drawing on Design surface without support or link to&nbsp;any Run- or Design-time properties<br> <br> Even if you want to invent biecycle reimplementing what already exists. Yo can compose (e.g. Composite or DropDownList, etc.) custom control at design-time and draw it symply by&nbsp;<br> &nbsp;&nbsp;&nbsp;public&nbsp;class&nbsp;CompositeControlDesigner&nbsp;:&nbsp;ControlDesigner&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;override&nbsp;string&nbsp;GetDesignTimeHtml()&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;Retrieve&nbsp;the&nbsp;controls&nbsp;to&nbsp;ensure&nbsp;they&nbsp;are&nbsp;created.<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ControlCollection&nbsp;controls&nbsp;=&nbsp;((Control)Component).Controls;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;base.GetDesignTimeHtml();<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> <br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;override&nbsp;void&nbsp;Initialize(IComponent&nbsp;component)&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(!(component&nbsp;is&nbsp;Control)&nbsp;&amp;&amp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;!(component&nbsp;is&nbsp;INamingContainer))&nbsp;{<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw&nbsp;new&nbsp;ArgumentException(<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;Component&nbsp;must&nbsp;be&nbsp;a&nbsp;container&nbsp;control.&quot;,&nbsp;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &quot;component&quot;);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;base.Initialize(component);<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br> &nbsp;&nbsp;&nbsp;&nbsp;}<br> }<br> </span> 2006-12-22T11:16:41-05:001507160http://forums.asp.net/p/1056458/1507160.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Thanks for your reply.</p> <p>1) The sample I showed you is just an example.&nbsp; I wrote it specifically to illustrate the problem I'm having.&nbsp; It is not my actual code.&nbsp; It is just an example of the problem I'm experiencing.&nbsp; The control does nothing on purpose, to show the problem with the designer, it's not meant to be executed at runtime.</p> <p>2) Yes, I'm sure there's a better option, but I don't have that luxury unfortunately.&nbsp; I work at a company that is upgrading our existing code from .Net&nbsp;1.1 to 2.0, with as little rewritting as possible.</p> <p>3) You mention that the designer code has problems.&nbsp; What problems?&nbsp; Everything looks ok to me.&nbsp; It doesn't need to access anything in the control as far as I know, it's simply meant to be a non-functional representation of the control.</p> <p>Given the sample code I provided, why can I not move it around in the designer?&nbsp; Why does it stay at the top left and only allow me to drag it into containers?&nbsp; What am I missing.&nbsp; This worked in 1.1.</p> <p>&nbsp;</p> <p>Thanks</p> 2006-12-23T03:44:20-05:001507316http://forums.asp.net/p/1056458/1507316.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) &lt;div&gt;<span class="205374810-23122006"><font face="Arial" size="2">Well,&nbsp; your ContextMenuTestDesigner doesn''t render ContextMenuTest control.<br> It&nbsp;does render&nbsp;content (and not even control) of another webcontrol (Table&nbsp;tbl) overwriting by it&nbsp;&nbsp;yout ContextMenuTest control</font></span>&lt;/div&gt; &lt;div&gt;<span class="205374810-23122006"><font face="Arial" size="2">This rendering &nbsp;is not related (or even persisted)&nbsp;into ContextMenuTest custom control&nbsp;in any way<br> <br> My advise is to&nbsp;form your custom control in order to render and not vice versa (to render it in order to&nbsp;form)&nbsp;</font></span>&lt;/div&gt; &lt;div&gt;<font face="Arial" color="#008080" size="2"><span class="205374810-23122006"></span></font>&nbsp;&lt;/div&gt; 2006-12-23T13:40:33-05:001507936http://forums.asp.net/p/1056458/1507936.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p align="left"><font size="&#43;0"><font size="2"><span class="647460203-25122006"><font face="Arial">GetDesignTimeHtml method should return <font size="3">the HTML generated by the control at run time by calling the control's <span class="docEmphasis">RenderControl</span> method. </font></font></font></font></span></p> <p align="left"><span class="647460203-25122006"><font face="Arial" size="2">Once againg, check the snippet I provided above!<br> <br> </font></span><font size="&#43;0"><font face="Arial" size="2"><span class="647460203-25122006">BTW&nbsp;Try to Right Click ---&gt; Add New Item--&gt;Component ---&gt; Web Custom Control</span></font></font></p> <p align="left"><font size="&#43;0"><span class="647460203-25122006"><font face="Arial" size="2">The following class is created<br> </font><font color="#0000ff"><br> <font face="Arial" size="2">namespace</font></font><font face="Arial" size="2"> ClassLibrary1<br> {<br> <font color="#0000ff">partial</font> <font color="#0000ff">class</font> </font><font face="Arial" color="#008080" size="2">CountControls<br> </font><font size="2"><font face="Arial">{<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span>private System.ComponentModel.IContainer components = null</font><font face="Arial">;</font></font></p> <p><font face="Arial" size="2">/// </font><font face="Arial" size="2">&lt;summary&gt;<br> ///</font><font face="Arial" size="2"> Clean up any resources being used.<br> /// </font><font face="Arial" size="2">&lt;/summary&gt;<br> /// &lt;param name=&quot;disposing&quot;&gt;true if managed resources should be disposed; otherwise, false.</font><font face="Arial" size="2">&lt;/param&gt;<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span>protected override void Dispose(bool</font><font size="2"><font face="Arial"> disposing)<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span>{<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;</span> </span> <font color="#0000ff">if</font> (disposing &amp;&amp; (components != <font color="#0000ff"> null</font></font><font face="Arial">))<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> </span></font></font><font face="Arial" size="2">{<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span></span></span></font><font face="Arial" size="2">components.Dispose();<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> </span></font><font face="Arial" size="2">}<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> </span></font><font size="2"><font face="Arial" color="#0000ff">base</font><font face="Arial">.Dispose(disposing);<br> </font></font><font face="Arial" size="2">}<br> </font><font color="#0000ff"><font face="Arial" size="2">#region</font></font><font face="Arial" size="2"> Component Designer generated code</font></p> <p><font face="Arial"><font size="2"><strong><font color="#808080">///</font><font color="#008000"> </font></strong><font color="#808080"><strong>&lt;summary&gt;<br> </strong></font></font></font><font face="Arial"><font size="2"><font color="#808080"><strong>///</strong></font><font color="#008000"><strong> Required method for Designer support - do not modify </strong><font color="#808080"><br> </font></font></font></font><font face="Arial"><font size="2"><font color="#808080"><strong>///</strong></font><font color="#008000"><strong> the contents of this method with the code editor.<br> </strong></font></font></font><font face="Arial"><font size="2"><font color="#808080">///</font><font color="#008000"> </font><font color="#808080">&lt;/summary&gt;</p> </font></font></font> <p><font size="2"><font face="Arial"><font color="#0000ff"><span class="647460203-25122006"><font color="#000000">&nbsp;&nbsp;&nbsp; </font></span>private</font> <font color="#0000ff">void</font></font><font face="Arial"> InitializeComponent()<br> </font></font><font face="Arial" size="2"><span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> {<br> <span class="647460203-25122006">&nbsp;&nbsp;&nbsp;&nbsp;<span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> </span></font><font size="2"><font face="Arial">components = </font><font face="Arial"><font color="#0000ff">new</font> System.ComponentModel.<font color="#008080">Container</font></font><font face="Arial">();<br> </font></font><font face="Arial" size="2"><span class="647460203-25122006">&nbsp;&nbsp;&nbsp; </span> }<br> </font><font face="Arial" color="#0000ff" size="2">#endregion<br> </font><font face="Arial" size="2">}<br> </font><font face="Arial" size="2">}</font></p> <p><span class="647460203-25122006"><font face="Arial" size="2">Where is it (<strong><font color="#008000">Required method for Designer support )</font></strong>?</font></span></p> </span></font> 2006-12-25T02:53:55-05:001508036http://forums.asp.net/p/1056458/1508036.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Forget what I wrote after BTW.<br> You should have run-time HTML generated in ContextMenuTest class and as final step the same mimicked in GetDesignTimeHtml () and not vice versa</p> 2006-12-25T06:57:41-05:001515751http://forums.asp.net/p/1056458/1515751.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Thanks for your responses, but I don't believe your assumptions are correct.&nbsp; You can&nbsp;render absolutely anything you want from GetDesignTimeHtml, and you don't have to render a single thing from the actual control, since the designer overrides it and we're not actually rendering the control at runtime.</p> <p>I have determined that the problem is actually related to WebControl.AddAttributesToRender.</p> <p>This method seems to add css positioning information to the control's main tag that allows it to move around in the designer.&nbsp; However, I don't know where it's getting those values from.&nbsp; ControlStyle is empty. Attributes is empty.&nbsp; There's something tricky going on in this function.</p> 2007-01-03T00:12:31-05:001515896http://forums.asp.net/p/1056458/1515896.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Found it.&nbsp; Once I copied the control's Attributes.CssStyles to the Attributes.CssStyles of the design-time main control, it started positioning correctly and all is well with the cosmos.</p> <p>Thanks.</p> 2007-01-03T02:49:55-05:001515902http://forums.asp.net/p/1056458/1515902.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>what your missing is that the new default is to wrap everything in a div, but you are not rendering that div.&nbsp; you drag it around, and the properties get set, but you are rendering it inline without positioning (from your snippet), so it moves back to top-left (inline display).</p> <p>In your rendered output, you need to set style=&quot;position:absolute; top:yyy; left:xxx&quot; etc from your target control if it's not empty&nbsp;and apply it to your design-time output.&nbsp; Also double check that you aren't using any deprecated functionality in your designer, since you are porting existing code.</p> <p>Lastly,&nbsp;you can always try posting the whole source (since I've been chastised for encouraging members to e-mail me such things) and not just what seems to be the relevant portion, as well as a sample host-page, if it behaves any differently according to host.</p> 2007-01-03T02:55:17-05:001516483http://forums.asp.net/p/1056458/1516483.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <blockquote><span class="icon-blockquote"></span> <h4>Phlow</h4> Found it.&nbsp; Once I copied the control's Attributes.CssStyles to the Attributes.CssStyles of the design-time main control, it started positioning correctly and all is well with the cosmos.</blockquote> <br> Congratulations!!!!!!!!<br> <br> What do you call &quot;design-time main control&quot; in terms of the code that you posted?<br> <br> Is it possible to give more exact snippet to reproduce your success? 2007-01-03T13:29:52-05:001517304http://forums.asp.net/p/1056458/1517304.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Sure, here's the same code I posted above, except I've added the copying of the CssStyle collection&nbsp;to make it work:</p> <p>&nbsp;</p> <pre class="prettyprint">public class ContextMenuTestDesigner : System.Web.UI.Design.ControlDesigner { public ContextMenuTestDesigner( ) { } public override bool AllowResize { get { return false; } } public override string GetDesignTimeHtml( ) { Table tbl = new Table( ); tbl.CellPadding = 1; tbl.CellSpacing = 1; tbl.Style.Add( HtmlTextWriterStyle.BackgroundColor, &quot;menu&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderCollapse, &quot;collapse&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderStyle, &quot;outset&quot; ); tbl.Style.Add( HtmlTextWriterStyle.BorderWidth, &quot;2px&quot; ); tbl.Style.Add( HtmlTextWriterStyle.Display, &quot;block&quot; ); tbl.Style.Add( HtmlTextWriterStyle.FontSize, &quot;8pt&quot; ); tbl.Style.Add( HtmlTextWriterStyle.FontFamily, &quot;Microsoft Sans Serif, Verdana, Arial, Helvetica&quot; ); tbl.Style.Add( HtmlTextWriterStyle.Padding, &quot;1px&quot; );</pre><pre class="prettyprint"><FONT color=#008080 size=2><P> ContextMenuTest</FONT><FONT size=2> ctxMenu </FONT><FONT color=#0000ff size=2>=</FONT><FONT size=2> </FONT><FONT color=#0000ff size=2>this.</FONT><FONT size=2>Component </FONT><FONT color=#0000ff size=2>as</FONT><FONT size=2> </FONT><FONT color=#008080 size=2>ContextMenuTest</FONT><FONT size=2>;</FONT></P><P><FONT size=2> <FONT color=#0000ff size=2>foreach</FONT><FONT size=2>( </FONT><FONT color=#0000ff size=2>string</FONT><FONT size=2> strKey </FONT><FONT color=#0000ff size=2>in</FONT><FONT size=2> ctxMenu</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>Attributes</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>CssStyle</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>Keys )</P><P> {</P><P> tbl</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>Attributes</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>CssStyle</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>Add( strKey, ctxMenu</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>Attributes</FONT><FONT color=#0000ff size=2>.</FONT><FONT size=2>CssStyle[strKey] );</P><P> }</P></FONT></FONT> <SPAN class=kwd><FONT color=#0000ff>for</FONT></SPAN>( <SPAN class=kwd><FONT color=#0000ff>int</FONT></SPAN> i = 1; i &lt;= 10; i++ ) { TableRow tr = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> TableRow( ); TableCell td = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> TableCell( ); <SPAN class=kwd><FONT color=#0000ff>if</FONT></SPAN>( (i % 3) != 0 ) <SPAN class=cmt><FONT color=#00d502>// 2 items, then a separator</FONT></SPAN> { WebControl wc = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> WebControl( HtmlTextWriterTag.Div ); <SPAN class=kwd><FONT color=#0000ff>if</FONT></SPAN>( i == 2 ) <SPAN class=cmt><FONT color=#00d502>// hilight 2nd item</FONT></SPAN> { wc.Style.Add( HtmlTextWriterStyle.BackgroundColor, <SPAN class=st><FONT color=#ff0000>"highlight"</FONT></SPAN> ); wc.Style.Add( HtmlTextWriterStyle.Color, <SPAN class=st><FONT color=#ff0000>"highlighttext"</FONT></SPAN> ); } <SPAN class=kwd><FONT color=#0000ff>else</FONT></SPAN> { <SPAN class=cmt><FONT color=#00d502>// alternate disabled look</FONT></SPAN> wc.Style.Add( HtmlTextWriterStyle.Color, ((i % 2) != 0) ? <SPAN class=st><FONT color=#ff0000>"black"</FONT></SPAN> : <SPAN class=st><FONT color=#ff0000>"inactivecaptiontext"</FONT></SPAN> ); } wc.Style.Add( HtmlTextWriterStyle.Cursor, <SPAN class=st><FONT color=#ff0000>"default"</FONT></SPAN> ); wc.Style.Add( HtmlTextWriterStyle.Overflow, <SPAN class=st><FONT color=#ff0000>"visible"</FONT></SPAN> ); wc.Style.Add( HtmlTextWriterStyle.Padding, <SPAN class=st><FONT color=#ff0000>"2px 18px 2px 14px"</FONT></SPAN> ); wc.Style.Add( HtmlTextWriterStyle.Width, <SPAN class=st><FONT color=#ff0000>"100%"</FONT></SPAN> ); LiteralControl lc = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> LiteralControl( ); lc.Text = <SPAN class=st><FONT color=#ff0000>"Menu Item "</FONT></SPAN> + i.ToString( ); wc.Controls.Add( lc ); td.Controls.Add( wc ); } <SPAN class=kwd><FONT color=#0000ff>else</FONT></SPAN> { td.Height = Unit.Pixel( 0 ); td.Style.Add( <SPAN class=st><FONT color=#ff0000>"border-top"</FONT></SPAN>, <SPAN class=st><FONT color=#ff0000>"1px solid threedshadow"</FONT></SPAN> ); td.Style.Add( <SPAN class=st><FONT color=#ff0000>"border-bottom"</FONT></SPAN>, <SPAN class=st><FONT color=#ff0000>"1px solid threedhighlight"</FONT></SPAN> ); } tr.Cells.Add( td ); tbl.Rows.Add( tr ); } StringWriter sw = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> StringWriter( ); HtmlTextWriter htw = <SPAN class=kwd><FONT color=#0000ff>new</FONT></SPAN> HtmlTextWriter( sw ); tbl.RenderControl( htw ); <SPAN class=kwd><FONT color=#0000ff>return</FONT></SPAN> sw.ToString( ); } } [ Designer( <SPAN class=kwd><FONT color=#0000ff>typeof</FONT></SPAN>( ContextMenuTestDesigner ) ), ToolboxData( <SPAN class=st><FONT color=#ff0000>"&lt;{0}:ContextMenuTest runat=\"</FONT></SPAN>server\<SPAN class=st><FONT color=#ff0000>"&gt;&lt;/{0}:ContextMenuTest&gt;"</FONT></SPAN> ) ] <SPAN class=kwd><FONT color=#0000ff>public class</FONT></SPAN> ContextMenuTest : System.Web.UI.WebControls.WebControl { <SPAN class=kwd><FONT color=#0000ff>public</FONT></SPAN> ContextMenuTest( ) : <SPAN class=kwd><FONT color=#0000ff>this</FONT></SPAN>( String.Empty ) { } <SPAN class=kwd><FONT color=#0000ff>public</FONT></SPAN> ContextMenuTest( <SPAN class=kwd><FONT color=#0000ff>string</FONT></SPAN> id ) : <SPAN class=kwd><FONT color=#0000ff>base</FONT></SPAN>( HtmlTextWriterTag.Div ) <SPAN class=cmt><FONT color=#00d502>// base( "c:ContextMenuTest" )</FONT></SPAN> { <SPAN class=kwd><FONT color=#0000ff>this</FONT></SPAN>.ID = id; } }</pre> 2007-01-03T22:11:04-05:001519246http://forums.asp.net/p/1056458/1519246.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>For my part at least, an item for the VS wish-list would be the ability to view the designer's source markup. As it is, we're flying blind.</p> <p>FWIW...</p> <p>&nbsp;</p> 2007-01-05T01:47:53-05:001519650http://forums.asp.net/p/1056458/1519650.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) &lt;div&gt;<span class="807092508-05012007"><span class="549135209-05012007"><font face="Arial" size="2">Ok, I have added <br> </font><font size="2"><font face="Arial">ContextMenuTest ctxMenu = this.Component as ContextMenuTest</font><font face="Arial">; </font><br> <font face="Arial">foreach (string strKey in</font></font><font face="Arial" size="2"> ctxMenu.Attributes.CssStyle.Keys) <br> {&nbsp;<br> <span class="549135209-05012007">&nbsp;&nbsp;&nbsp; </span>tbl.Attributes.CssStyle.Add(strKey, ctxMenu.Attributes.CssStyle[strKey]); <br> }<br> </font><span class="549135209-05012007"><font size="2"><font color="#0000ff"><font face="Arial">to<br> </font></font></font>GetDesignTimeHtml() of ContextMenuTestDesigner<br> (and I have not checked the rest)</span> <p><span class="549135209-05012007">What is going on is that design-time&nbsp;is quering&nbsp;&nbsp;<br> <font face="Arial"><font size="2"><font color="#0000ff">ContextMenuTest<span class="549135209-05012007"> </font></font><font face="Arial" size="2">custom control and inserting the corresponding values.</font></span></font></p> <p><font size="&#43;0"><font size="2"><span class="549135209-05012007"></span></font></font></span></span><span class="549135209-05012007"><font face="Arial"><font size="2"><font color="#008080">In design-time the value of <strong><u>string str = </u></strong><font color="#0000ff"><font color="#008080"><strong><u>sw.ToString( )</u></strong> </font>(</font></font><font color="#0000ff">from</font></font></font><font color="#008080"><font size="2"><font face="Arial"><font color="#0000ff"> <span class="kwd">return</span></font>&nbsp; of </font><font face="Arial">GetDesignTimeHtml)</font></font></p> <p><span class="549135209-05012007"></span><font face="Arial" color="#0000ff" size="2">i</font><span class="549135209-05012007"><font face="Arial" color="#0000ff" size="2">s:<br> </font></span><span class="549135209-05012007"></span><span class="549135209-05012007"></span><font face="Arial" color="#0000ff" size="2">1<span class="549135209-05012007">)</span><br> </font>undefined<span class="549135209-05012007">f in Source view of aspx<font color="#008080"><font face="Arial" color="#0000ff" size="2"><br> </font><span class="807092508-05012007"><font face="Arial" color="#0000ff" size="2">&lt;cc1:ContextMenuTest ID=&quot;ContextMenuTest1&quot; runat=&quot;server&quot; Style=&quot;left: 42px; position: absolute;<span class="549135209-05012007"> </span>top: 97px&quot; /&gt;<br> </font></font>then&nbsp;<font color="#008080"><font face="Arial" color="#0000ff" size="2"><br> </font></span></span><font face="Arial" size="2">&nbsp;&nbsp;str&nbsp;&quot;&lt;table cellspacing=\&quot;1\&quot; cellpadding=\&quot;1\&quot; border=\&quot;0\&quot; <strong><u>style=\&quot;LEFT:42px;POSITION:absolute;TOP:97px</u>;</strong>background-color:menu;border-collapse:collapse;border-style:outset;border-width:2px;display:block;font-size:8pt;font-family:Microsoft Sans Serif, Verdana, Arial, Helvetica;padding:1px;\&quot;&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 1\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;background-color:highlight;color:highlighttext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 2\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 4\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 5\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 7\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 8\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 10\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;\r\n&lt;/table&gt;&quot;&nbsp;</font></font></p> </font></span> <p></span><span class="549135209-05012007"><font face="Arial" size="2">2)<br> </font>i<span class="549135209-05012007">f in Source view of aspx<br> <span class="807092508-05012007"><font face="Arial" color="#0000ff" size="2"><font face="Arial" size="2">&lt;cc1:ContextMenuTest ID=&quot;ContextMenuTest1&quot; runat=&quot;server&quot; Style=&quot;left: 42px; position: absolute;<span class="549135209-05012007"> </span>top: 97px&quot; /&gt;<br> </font></font>then&nbsp;<br> </span></span><span class="549135209-05012007"></span><font size="2"><font face="Arial" size="2"><font color="#0000ff"><font face="Arial">s<span class="549135209-05012007">tr </font></font></font></font>contains<font size="2"><font face="Arial" size="2"><font color="#0000ff"><font face="Arial">:<br> <span style="font-size:12pt; font-family:'Times New Roman'"><font color="#000000">&quot;&lt;table cellspacing=\&quot;1\&quot; cellpadding=\&quot;1\&quot; border=\&quot;0\&quot; style=\&quot;background-color:menu;border-collapse:collapse;border-style:outset;border-width:2px;display:block;font-size:8pt;font-family:Microsoft Sans Serif, Verdana, Arial, Helvetica;padding:1px;\&quot;&gt;\r\n\t&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 1\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;background-color:highlight;color:highlighttext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 2\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 4\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 5\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:black;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 7\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 8\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td style=\&quot;height:0px;border-top:1px solid threedshadow;border-bottom:1px solid threedhighlight;\&quot;&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;&lt;tr&gt;\r\n\t\t&lt;td&gt;&lt;div style=\&quot;color:inactivecaptiontext;cursor:default;overflow:visible;padding:2px 18px 2px 14px;width:100%;\&quot;&gt;\r\n\t\t\tMenu Item 10\r\n\t\t&lt;/div&gt;&lt;/td&gt;\r\n\t&lt;/tr&gt;\r\n&lt;/table&gt;&quot;<br> 3)<br> you may see (in very time- and resource-consuming manner) what is output while you move your control<br> Well, it is clear that if there is no code<br> <font color="#0000ff"><font size="2">&nbsp;&nbsp;&nbsp; foreach</font></font><font size="2"> (<font color="#0000ff">string</font> strKey <font color="#0000ff">in</font> ctxMenu.Attributes.CssStyle.Keys) <br> &nbsp;&nbsp; { tbl.Attributes.CssStyle.Add(strKey, ctxMenu.Attributes.CssStyle[strKey]); }<br> </font></font></font></font></font></font><span class="549135209-05012007">then there is no way to have synchronization between control and its design view.<br> <br> Here I can only to return to the&nbsp;advise I gave from the beginning<br> construct control and visualize it on design surface (and not vice versa)<br> <font size="2"><font face="Arial" size="2"><font color="#0000ff"><font face="Arial"><font color="#000000"><font size="2"><font face="Arial" color="#0000ff"><br> </font></span></font></font></font></font></font></font><span class="549135209-05012007">How to debug at design-time,<br> you may see here<br> <font size="2"><font face="Arial" size="2"><font color="#0000ff"><font face="Arial"><font color="#000000"><font face="Arial" color="#0000ff"><font size="2"><span id="ctl00_ctl01_bcr_ctl00___ForumName">''how to debug a custom web control&quot; post</span><br> <a href="http://forums.asp.net/thread/1516665.aspx">http://forums.asp.net/thread/1516665.aspx</a><br> <br> </font></font></font></font></font></font></font>with a few additional comments.<br> Second instance of VS&nbsp;(and custom control design-time debugging) really starts only if your &nbsp;&nbsp;code with breakpoint is currently opened.<br> <br> The breakpoint is hit when you switch in second VS2005 from source view to design view.<br> (if you insert your control manually to aspx)</span></span></span></span></p> &lt;/div&gt; 2007-01-05T09:44:43-05:001519669http://forums.asp.net/p/1056458/1519669.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>Errata in 2) should be<br> <font color="#0000ff" size="2">&lt;</font><font color="#800000" size="2">cc1</font><font color="#0000ff" size="2">:</font><font color="#800000" size="2">ContextMenuTest</font><font size="2"> </font><font color="#ff0000" size="2">ID</font><font color="#0000ff" size="2">=&quot;ContextMenuTest1&quot;</font><font size="2"> </font><font color="#ff0000" size="2">runat</font><font color="#0000ff" size="2">=&quot;server&quot;</font><font size="2"> </font><font color="#0000ff" size="2">/&gt;<br> </font>without <font color="#0000ff" size="2">style=<br> <br> </font>I am really angry why I cannot edit my own posts.<br> I am rejected any rights on my own contributions... thinking to abandon this forum&nbsp;</p> 2007-01-05T10:07:44-05:001519675http://forums.asp.net/p/1056458/1519675.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) <p>I'm not quite sure I'm following you...</p> <p>Are you talking about&nbsp;displaying a context menu item while in Design View that, when activated, displays the design-time HTML?</p> <p>&nbsp;</p> 2007-01-05T10:12:02-05:001519790http://forums.asp.net/p/1056458/1519790.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) I continued to respond to the original question, <br> i.e. that original version&nbsp;of code&nbsp;was throwing HTML markup on design surface without any connection/synchronization with control,<br> so it even&nbsp;did n''t have any&nbsp;place &nbsp;to&nbsp; persist coordinates for moving the design-time representation<br> <br> Phlow presented solution of introducing <br> ContextMenuTest ctxMenu = this.Component as ContextMenuTest<font face="Arial">; </font> <br> <font face="Arial">foreach (string strKey in</font><font face="Arial" size="2"> ctxMenu.Attributes.CssStyle.Keys) <br> {&nbsp;<br> <span class="549135209-05012007">&nbsp;&nbsp;&nbsp; </span>tbl.Attributes.CssStyle.Add(strKey, ctxMenu.Attributes.CssStyle[strKey]); <br> }<br> into GetDesignTimeHtml() of ContextMenuTestDesigner<br> after which the design-time representation of ContextMenuTest control got ability to move since it really already has been connected by this to real control<br> <br> ContextMenuTest is the custom control class of original question.</font> &lt;div&gt;<span class="755593411-05012007"><font face="Arial" size="2"><font face="Arial" size="2"><br> As I understood you&nbsp;call by &quot;context menu&quot;&nbsp;the &nbsp;smart tags of a custom control.<br> In this case there is no smart tags whatsoever, the names is due to the names of classes presented by PhLow<br> </font></font></span>&lt;/div&gt; 2007-01-05T12:23:32-05:001519794http://forums.asp.net/p/1056458/1519794.aspx/1?Re+Custom+control+can+t+be+moved+from+the+top+left+corner+in+the+designer+NET+2+0+VC+2005+Re: Custom control can't be moved from the top left corner in the designer. (.NET 2.0 VC#2005) I continued to respond to the original question, <br> i.e. that original version&nbsp;is throwing HTML amrkup on design surface without any connection/synchronization with control,<br> so it even&nbsp;doesn''t have any&nbsp;place &nbsp;to&nbsp; persist coordinates for moving<br> <br> Phlow presented solution of introducing <br> ContextMenuTest ctxMenu = this.Component as ContextMenuTest<font face="Arial">; </font> <br> <font face="Arial">foreach (string strKey in</font><font face="Arial" size="2"> ctxMenu.Attributes.CssStyle.Keys) <br> {&nbsp;<br> <span class="549135209-05012007">&nbsp;&nbsp;&nbsp; </span>tbl.Attributes.CssStyle.Add(strKey, ctxMenu.Attributes.CssStyle[strKey]); <br> }<br> into GetDesignTimeHtml() of ContextMenuTestDesigner<br> after which the ContextMenuTest control got ability to move since it really already has been connected by this to real control<br> <br> ContextMenuTest is the custom control class of original question.</font> &lt;div&gt;<span class="755593411-05012007"><font face="Arial" size="2"><font face="Arial" size="2"><br> As I understood you&nbsp;call by &quot;context menu&quot;&nbsp;the &nbsp;smart tags of a custom control.<br> In this case there is no smart tags whatsoever, the names are due to the names of classes in the code presented by PhLow<br> </font></font></span>&lt;/div&gt; 2007-01-05T12:26:47-05:00