How to use HtmlControlDesigner

Discussion in 'ASP .Net Building Controls' started by Karsten Lundsgaard, Aug 1, 2003.

  1. Hi,
    I'm making some runtime-invisible-WebControls, which
    should be visible at designtime like the "Repeater"-
    component in the "Web Forms Toolbox", and invisible at
    runtime.

    I think that I have to use HtmlControlDesigner.

    Is there somebody who have an exsample on how to make the
    DesignTime render function.

    Regards

    Karsten Lundsgaard
     
    Karsten Lundsgaard, Aug 1, 2003
    #1
    1. Advertising

  2. I don't get why you couldn't just use a designer derived from
    ControlDesigner?

    The following example is from "Professional ASP.NET Server Controls",
    copyright 2002 Wrox Press, page 345:

    public class WroxButtonDesigner : ControlDesigner
    {
    public WroxButtonDesigner()
    {
    }

    public override string GetDesignTimeHtml()
    {
    // Get a typed reference to the button being designed.
    WroxButton wb = (WroxButton) base.Component;

    Panel pnl = new Panel();
    // Make it look just as the button control.
    pnl.CopyBaseAttributes(wb);
    pnl.Controls.Add(wb);
    // Add a dotted border and adjust the new size
    pnl.BorderStyle = BorderStyle.Dotted;
    pnl.BorderWidth = new Unit(2, UnitType.Point);
    pnl.Height = new Unit(pnl.Height.Value + 4);
    pnl.Width = new Unit(pnl.Width.Value + 4);
    // Return the rendered string.
    return GetRenderHtml(pnl);
    }

    /// <summary>
    /// Provides the string representation of a rendered control.
    /// </summary>
    /// <param name="control">The control to render.</param>
    /// <returns>The HTML representing the control.</returns>
    private string GetRenderHtml(Control control)
    {
    StringWriter text = new StringWriter();
    HtmlTextWriter writer = new HtmlTextWriter(text);
    control.RenderControl(writer);
    return text.ToString();
    }
    }

    --
    John Saunders
    Internet Engineer


    "Karsten Lundsgaard" <> wrote in message
    news:0e0d01c35821$d12da360$...
    > Hi,
    > I'm making some runtime-invisible-WebControls, which
    > should be visible at designtime like the "Repeater"-
    > component in the "Web Forms Toolbox", and invisible at
    > runtime.
    >
    > I think that I have to use HtmlControlDesigner.
    >
    > Is there somebody who have an exsample on how to make the
    > DesignTime render function.
    >
    > Regards
    >
    > Karsten Lundsgaard
    >
    >
     
    John Saunders, Aug 1, 2003
    #2
    1. Advertising

  3. Thanks. It seems like the ControlDesigner will do the job.

    BTW : The MSDN description of the ControlDesigner Class
    has a good example.

    Karsten Lundsgaard
     
    Karsten Lundsgaard, Aug 4, 2003
    #3
    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. Replies:
    6
    Views:
    7,164
  2. M K
    Replies:
    11
    Views:
    7,080
    woods_jemmy
    Apr 9, 2008
  3. Simon
    Replies:
    1
    Views:
    457
    Henri
    Nov 9, 2004
  4. =?Utf-8?B?S2hhaXJvbA==?=
    Replies:
    0
    Views:
    366
    =?Utf-8?B?S2hhaXJvbA==?=
    Dec 10, 2004
  5. =?Utf-8?B?SmVmZiBLZXNpbmdlcg==?=

    Common Web functions dll (Used to use MTS, what do I use in .NET

    =?Utf-8?B?SmVmZiBLZXNpbmdlcg==?=, Dec 28, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    467
    charlie
    Apr 30, 2005
Loading...

Share This Page