all groups > asp.net building controls > june 2005 >
You're in the

asp.net building controls

group:

Rendering Custom Control during design time


Rendering Custom Control during design time Joey Lee
6/30/2005 12:00:00 AM
asp.net building controls:
Hi,

I have been creating simple custom controls that is able to be added to the
Visual Studio toolbox and drag & drop to my aspx pages. The main thing i
need is visual representation during design time.

In order to do this, i override the render method and insert html codes.

However I would like to do more by inserting web controls, can this be done?
Using other ways like user control or overriding the createchildcontrol of
controls does not allow visual representation design time.

I was thinking of creating a simple control which have a label and a
dropdownlist with autopostback. This control is used to control the display
row for my datagrid. How do i code web controls and allow postback that will
somehow allow me again to change the display row of my data grid.

Any ideas or pointer?

Thanks

Joey

Re: Rendering Custom Control during design time Joey Lee
6/30/2005 12:00:00 AM
Hi,

I had problem making it work from your example. But I manage to find the
correct resources from your code.

Thanks :) , without your example I would still be lost

Here is the url which i found that allow me to manage design time as well as
use those web controls behind to make things work

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconnetframeworkdesign-timearchitecture.asp

Joey

[quoted text, click to view]

Re: Rendering Custom Control during design time Matt
6/30/2005 10:36:07 AM
What worked for me was to create my own Designer class (extending
System.Web.UI.Design.ControlDesigner). Then you override
GetDesignTimeHtml() method and in that method you can do stuff like:

StringWriter sw = new StringWriter();
HtmlTextWriter tw = new HtmlTextWriter(sw);

Label lblLink = new Label();
lblLink.Text = "<";
lblLink.ForeColor = System.Drawing.Color.Blue;
lblLink.Style.Add("text-decoration", "underline");
lblLink.RenderControl(tw);

If you want to get a reference to the actual control to read a property
or something:

MyCustomControl myCC = (MyCustomControl)this.Component;
AddThis Social Bookmark Button