Adding a Hyperlink control to a PlaceHolder

  • Thread starter Thread starter Mark Rae
  • Start date Start date
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
 
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
 
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...?
 
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

Back
Top