Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Rendering Custom Control during design time

Reply
Thread Tools

Rendering Custom Control during design time

 
 
Joey Lee
Guest
Posts: n/a
 
      06-30-2005
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


 
Reply With Quote
 
 
 
 
Matt
Guest
Posts: n/a
 
      06-30-2005
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;

 
Reply With Quote
 
 
 
 
Joey Lee
Guest
Posts: n/a
 
      07-01-2005
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/de...chitecture.asp

Joey

"Matt" <> wrote in message
news: oups.com...
> 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;
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Discovering CSS refs in page custom control resides during design time. HTML ASP .Net Building Controls 1 01-28-2006 12:37 PM
Design time rendering of a composite custom web control Barry Carr ASP .Net 4 01-15-2004 09:03 PM
Rendering DataGrid in a custom control at design time Sam Fields ASP .Net Datagrid Control 0 01-15-2004 08:08 PM
Rendering DataGrid in a custom control at design time Sam Fields ASP .Net Web Controls 0 01-15-2004 08:08 PM
Rendering DataGrid in a custom control at design time Sam Fields ASP .Net Building Controls 0 01-15-2004 07:41 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57