Groups | Blog | Home
all groups > asp.net building controls > february 2006 >

asp.net building controls : Setting web custom control properties at design time


N Kumar
2/21/2006 4:36:05 AM
I am developing a Web custom control whose properties (such as text) I would
like to map to other control properties (such as textbox1.text) or variables
of the web form at design time. Is this possible?
--
N Kumar
2/22/2006 8:46:29 PM
Thanks Teemu.

But I am not looking to access the child controls within the composite
control. This is definitely possible as you indicated.

What I am looking for is, I have a, say composite control with property say
Text. Now when a developer uses my control and tries to assign the Text
property through Property window, I would like to show him/her, the other
Textbox names in that web form. Say the developer has assigned (mapped) to
Textbox1, at runtime, the Text property of the composite control should take
the text value from Textbox1.

Is such a mapping possible?

--
NK


[quoted text, click to view]
N Kumar
2/22/2006 8:58:43 PM
Thanks Teemu.

But I am not looking to set the property value from child controls of the
composite control. This is very much possible as you indicated.

What I am trying to do is, say, I have a composite control with a property
Text. Now when a developer uses my control, and when he/she tries to assign
the Text property through the property window, I would like to show him a
list which has names of other Textboxes in the Web form. Now say, the
developer has assigned (mapped) it to Textbox1, then at runtime, the Text
property of Textbox1 should be assigned to the Text property of the composite
control, during initialization of the Web form.

Is this possible?
--
NK


[quoted text, click to view]
Teemu Keiski
2/22/2006 9:10:23 PM
Hi,

yes it is. One way is to write a composite server control.

Here's a sample
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcompositecontrolsample.asp

And here's one good article: http://aspalliance.com/359

If you use ASp.NET 2.0 see: http://dotnet.sys-con.com/read/171169.htm
(with ASP.NET 2.0 you'd inherit directly from CompositeControl base class)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


[quoted text, click to view]

Teemu Keiski
2/23/2006 10:13:26 PM
Hi,

basically providing a list of controls can be done with a custom type
converter, when it would pick IDs of other controls and set such into the
property.Is that what you mean? For example similar when you set
ControlToValidate of a validator control. it shows you list of all controls
having ValidationProperty attribute applied. Yes, such is done with a custom
type copnverter.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke

[quoted text, click to view]

AddThis Social Bookmark Button