Groups | Blog | Home
all groups > asp.net building controls > october 2004 >

asp.net building controls : Script control


Magne Ryholt
10/16/2004 4:25:11 PM
I have made a control based on System.Web.UI.WebControls.WebControl which
override the Render method to emit a script
(by using the Page.RegisterStartupScript() method)
This works fine.

This control does not render any HTML code except the mentioned script,
therefore I would like to put the component (using VS.net 2003) on the
component tray instead of the form.
(otherwise it takes up space on thye form)

Anyone knows if this is possible ?


Jos
10/17/2004 9:23:38 AM
[quoted text, click to view]

I don't think so.
To get your control in the component tray, you need to
derive from Component instead of WebControl.

But Component doesn't have a Render method.

However, you could associate your control with a class
derived from ControlDesigner, which would just emit some
small code to show in the designer. This would solve
your problem.

Look here:
http://msdn.microsoft.com/asp.net/default.aspx?pull=/library/en-us/dnaspp/html/aspnet-adddesigntimesupport.asp

--

Jos

Magne Ryholt
10/17/2004 11:32:42 AM
Thanks for your answer
I beleive your answer indicates to emit some HTML for showing the control in
design time, but still it will occupy space in the form designer ?
I thought it might be a possibility to make it a "component" (in the
component tray) because System.Web.UI.WebControls.WebControl inherits from
System.Web.UI.Control
which in turn inherits from (implements) IComponent, but I cannot find
anything useful there either.

Anyway, it is not a big problem, it just reminds me of the annoying way e.g.
Visual Basic 6.0 showed (runtime-invisible)components in the form and took
up some space :)
(but VB 6.0 didn't have any "component tray")

[quoted text, click to view]


Jos
10/17/2004 4:33:36 PM
[quoted text, click to view]

Not if you make it emit an empty string.

--

Jos

Magne Ryholt
10/17/2004 10:01:23 PM
But then it is so difficult to find it on the design surface
[quoted text, click to view]


AddThis Social Bookmark Button