public static string RenderDesignerControl(Control control)
{
string height = "auto";
string width = "auto";
string canResize = "true";
string canDrop = "false";
string id = control.UniqueID;
WebControl wc = control as WebControl;
if (wc != null) {
height = wc.Height.ToString ();
width = wc.Width.ToString ();
}
else
{
canResize = "false";
}
//TODO: is there a better way to make tiny controls appear a decent size?
if (height == "" || height == "auto") height = "20px";
if (width == "" || width == "auto") width = "20px";
//render the control
//TODO: use designer, when they're written
OnPreRenderMethodInfo.Invoke (control, new object[] {EventArgs.Empty});
System.IO.StringWriter strWriter = new System.IO.StringWriter ();
System.Web.UI.HtmlTextWriter writer = new System.Web.UI.HtmlTextWriter (strWriter);
control.RenderControl (writer);
writer.Close ();
strWriter.Flush ();
string content = strWriter.ToString ();
strWriter.Close ();
return string.Format (ControlSubstituteStructure, id, width, height, canDrop, canResize, content);
}