HTMLControl bafflement

G

Guest

Hi folks

I want to add a <ul> list with some <li> items in .net code behind on the fly

I was under the impression that you could instantiate any HTML control by
using the HTMLControl class with constructor parameters like so

HTMLControl("ul")

the purpose being that I could then program some of the attributes of the ul
or the li using logic....
please don't worry if this is the best way but how can I get an unordered
list written out in code rather than in declarative HTML

I don't want to use the Literal control class, because I want some
server-side programming here


Regards and many thanks in advance
CharlesA
 
G

Guest

'you would create a <ol> tag like this
Dim ol As New HtmlGenericControl("ol")

'you manage its attributes like this
ol.Attributes.Add("type", "circle")

'you can add it to list item like this
Dim li As New HtmlGenericControl("li")
li.InnerText = "some text"
li.Attributes.Add("class", "listitemCss")
ol.Controls.Add(li)

'then add it to a placeholder on your aspx page
PlaceHolder1.Controls.Add(ol)
 

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,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top