adding child controls problem

D

Daves

I'm iterating through all controls in ControlPlaceholder to locate specific
HyperLink controls. When found I want to add an Image control right after -
I'm visually placing seperator images between hyperlinks. When I do
_hl.Controls.Add(_img) the hyperlinks dissapear, although the image is
there?!

foreach(...)
{
if (_ctrl3 is HyperLink)
{
HyperLink _hl = (HyperLink) _ctrl3;
Image _img = new Image();
_ img.ImageUrl = "~/img/seperator.gif";
_hl.Controls.Add(_img);
}
}
 
R

Rob MacFadyen

Daves,

If what you're looking for as an end result is:
<asp:hyprlink ..></asp:hyperlink><asp:img ..></asp:img>

The you need the AddAt method of the container.

From what you've said I think you're ending up with:
<asp:hyprlink ..><asp:img ..></asp:img></asp:hyperlink>

Does that help?

Rob MacFadyen
 
D

Daves

yep it did. Thanks.
Rob MacFadyen said:
Daves,

If what you're looking for as an end result is:
<asp:hyprlink ..></asp:hyperlink><asp:img ..></asp:img>

The you need the AddAt method of the container.

From what you've said I think you're ending up with:
<asp:hyprlink ..><asp:img ..></asp:img></asp:hyperlink>

Does that help?

Rob MacFadyen
 

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

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top