Control Render Method Problem and the Visual Studio Designer

Discussion in 'ASP .Net Building Controls' started by Pete, Dec 10, 2003.

  1. Pete

    Pete Guest

    Hello List,
    I have a web control library that has both Render and OnPreRender methods.
    My problem is that when I drag and drop my control onto
    the designer in Visual Studio my control shows up as very tiny green arrow.
    Obviously the VS designer is trying to add any HTML
    attributes to the properties window, but in my case I have none. I'm just
    want the HtmlTextWriter to spit out lines of DHTML. My
    render method is below. I've search through the docs System.ComponetModel
    attributes and can't find what I need to completely hide
    my Render method from the VS designer. My control works flawlessly but I
    need it show up correctly at design time. If I completely
    rip out the Render method my control shows up in the VS designer as it
    should. I've also added my designer class for my control.
    Thanks in advance.


    #region Render Method
    [EditorBrowsable(EditorBrowsableState.Never)]
    protected override void Render(HtmlTextWriter writer)
    {
    base.Render (writer);

    String topBC = this.TopBarColor.ToKnownColor().ToString();
    String btnISD = this.BtnImagesSrcDirectory;

    writer.WriteLine("<div
    id='docWindow'style='position:absolute;background-color:#000000;left:0px;top
    :0px;display:none'>");

    if (TopBarVisible == true)
    {
    writer.WriteLine("<div align='right'style='background-color:" + topBC +
    "'><img src='" + btnISD +
    "Maximize.gif'id='maxRestoreWindow'onClick='MaxRestoreWindow(" + btnISD +
    ")'><img src='" + btnISD +
    "Close.gif'onClick='CloseWindow()'></div>");
    }

    writer.WriteLine("<iframe id='fooiFrame' src='' width=100%
    height=100%></iframe></div>");
    }
    #endregion Render Method



    public class TheControlDesigner : ControlDesigner
    {
    protected override string GetEmptyDesignTimeHtml()
    {
    StringBuilder sb = new StringBuilder("");
    sb.Append("<table bgcolor=Green<tr><td align=center>");
    sb.Append("<span style='font-family:verdana;font-size:10px;'>");
    sb.Append("test <b>test</b>Control</span>");
    sb.Append("</td></tr><tr><td align=center>");
    sb.Append("<span style='font-family:verdana;font-size:10px;'>");
    sb.Append("Courtesy of <b>test</b></span>");
    sb.Append("</td></tr></table>");

    return sb.ToString();
    }
    }
     
    Pete, Dec 10, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ben Fidge
    Replies:
    0
    Views:
    1,828
    Ben Fidge
    Feb 26, 2006
  2. Thirumalai
    Replies:
    0
    Views:
    714
    Thirumalai
    May 22, 2006
  3. xman
    Replies:
    0
    Views:
    544
  4. xman
    Replies:
    1
    Views:
    640
    Victor Bazarov
    Aug 17, 2005
  5. ebo beecham via .NET 247

    Cant Render Page Control with Visual Studio 2005 Beta

    ebo beecham via .NET 247, Apr 9, 2005, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    183
    Ken Cox [Microsoft MVP]
    Apr 9, 2005
Loading...

Share This Page