Add control to a placeholder

C

Carlos Cruz

hi,

I want to add controls (hyperlinks) dynamically in code into a placeholder.
I manage to add them but they appear in the same line and I want to show
each hyperlink in a diferente line (like a left menu).
How can I do this???

Thanks
CC
 
K

Ken Cox [Microsoft MVP]

Hi Carlos,

You could add hyperlink controls and then a literal control containing a
<br> after each one like this:

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim intCounter As Integer
Dim hlnk As HyperLink
Dim litrl As Literal
For intCounter = 0 To 5
hlnk = New HyperLink
hlnk.NavigateUrl = intCounter.ToString & ".aspx"
hlnk.Text = "Link " & intCounter.ToString
litrl = New Literal
litrl.Text = "<br>"
PlaceHolder1.Controls.Add(hlnk)
PlaceHolder1.Controls.Add(litrl)
Next
End Sub

Does this help?

Ken
Microsoft MVP [ASP.NET]
 

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,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top