The fastest (and the most ugliest) way that answers your question is this:
Solution 1
.ASPX file
<ul class="ulSpecialty" id="ulSpecialty_selector" runat="server">
</ul>
.ASPX.cs file (code behind)
protected void Page_Load(object sender, EventArgs e)
{
//the ugly way, fastest that answers your question
TheUglyWay();
}
private void TheUglyWay()
{
StringBuilder innerHtml = new StringBuilder();
for(var i = 0; i < 3; i++){
string li = @"
<li class=""liSubSpecialty active"" data-trait-id=""9"">
<a href=""test.htm"" class=""premote trait-link large btn"" data-trait-id=""9"">
<span class=""check""><i class=""icon icon-ok""></i></span>
<span class=""name"">Cardiology</span>
<span class=""count"">6</span>
</a>
</li>";
innerHtml.AppendLine(li);
}
ulSpecialty_selector.InnerHtml = innerHtml.ToString();
}
The above method is by far the baddest thing you can do to solve your problem. Even if it works, the code does not comply with the .NET "way" of writing web applications, it is unmaintainable and ... just ugly :).
There are better ways, here's one of them that uses the Repeater control:
Solution 2
.ASPX file
<asp:Repeater runat="server" ID="rptSpeciality">
<HeaderTemplate>
<ul class="ulSpecialty" id="ulSpecialty_selector">
</HeaderTemplate>
<ItemTemplate>
<li class="liSubSpecialty active" data-trait-id="9">
<a href="test.htm" class="premote trait-link large btn" data-trait-id="9">
<span class="check"><i class="icon icon-ok"></i></span>
<span class="name">Cardiology</span>
<span class="count">6</span>
</a>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
.ASPX.cs file (code behind)
protected void Page_Load(object sender, EventArgs e)
{
//the better way, using a repeater
TheBetterWay();
}
private void TheBetterWay()
{
//bind the repeater to an array of three elements
rptSpeciality.DataSource = new object[] { null, null, null };
rptSpeciality.DataBind();
}
And of course, using this second solution you can insert data from code behind into the li
tags using databinding expressions