Adding a Hyperlink control to a PlaceHolder

M

Mark Rae

Hi,

I have an <asp:placeHolder control on a page in an ASP.NET 1.1 app, as
follows:

<td nowrap><asp:placeHolder ID="phClientWebsite"
Runat=server>&nbsp;</asp:placeHolder></td>

Server-side, I'm running the following code:

HyperLink lnkWebsite = new HyperLink();
lnkWebsite.NavigateUrl = dr["strWebsite"].ToString();
lnkWebsite.Target = "_blank";
Page.FindControl("phClientWebsite").Controls.Add(lnkWebsite);


However, the hyperlink is not displayed on the page, although it appears in
the HTML when I do a View Source. Incidentally, if I copy the HTML from View
Source into a stand-alone HTML page, the hyperlink is displayed.

Incidentally, I've also tried this with an <asp:Label control, to no
avail...

What am I doing wrong?

Any assistance gratefully received.

Mark Rae
 
K

Ken Cox [Microsoft MVP]

Hey Mark,

If link is showing in the source code but not being rendered properly by the
browser, I'd question whether the HTML is well formed.

Ken
 
M

Mark Rae

If link is showing in the source code but not being rendered properly by
the browser, I'd question whether the HTML is well formed.

Surely this means that it's well formed...?
 
J

Jos

Mark said:
Hi,

I have an <asp:placeHolder control on a page in an ASP.NET 1.1 app, as
follows:

<td nowrap><asp:placeHolder ID="phClientWebsite"
Runat=server>&nbsp;</asp:placeHolder></td>

Server-side, I'm running the following code:

HyperLink lnkWebsite = new HyperLink();
lnkWebsite.NavigateUrl = dr["strWebsite"].ToString();
lnkWebsite.Target = "_blank";
Page.FindControl("phClientWebsite").Controls.Add(lnkWebsite);


However, the hyperlink is not displayed on the page, although it
appears in the HTML when I do a View Source.

I noticed that you don't set the "Text" property of your Hyperlink control.
This will cause it to be invisible in the page.
Incidentally, if I copy
the HTML from View Source into a stand-alone HTML page, the hyperlink
is displayed.

This is weird.
 

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,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top