Control Reuse

G

GingerNinja

Hi,

I'm working on a web control at the moment which creates a simple form
with some fields and some labels, all on one line.

The output is fine and everything is ok, however I want to control the
space between the controls with a spacer image. Since there are 4
controls I will need 4 spacer images at 5px wide each to create a nice
even gap between each control so it doesnt look too bunched up.

I've tried creating one image control:
Dim spacer as New Image
spacer.imageurlBLAHBLAHwidth etc

and then adding this to the form between each control
Me.Controls.Add(lblUname)
Me.Controls.Add(spacer)
Me.Controls.Add(txtUname)
Me.Controls.Add(spacer)
.......... etc

However when the control is rendered it only displays the image in in
the place where it was last added.

Now I'm sure your all going to say thats how its supposed to be, which
is fine, however I would like to know how you can reuse control (like
an image control) to appear several times without having to declare a
new one each time. I'm sure its just a syntax thing, I supposed I
could just output the HTML as in:
Output.Write("{0} {1} {2}","<H2>", "Hello World", "</H2>")

But I'm kind of curious if control reuse in this way is possible.
 
K

Kevin Spencer

You have a more serious problem on your hands, which, if you solve it, will
render your present problem moot. Using an Image Control to create a static
HTML space in a Server Control is a total waste of server-side resources.
Images controls are useful if you want to change anything about the image.
Otherwise, use static HTML images.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
G

Graham Innes

Fair comment thanks for the input. I must admit I'm not supprised to
hear that, however it doesnt really answer my final question:
But I'm kind of curious if control reuse in this way is possible?

I dont mean to be rude, there maybe a situation where this is usefull,
it matters not really, heck I just want to satisfy my curiosity on this.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,151
Latest member
JaclynMarl
Top