I have used you code do add li(List element) dynamically and its working perfectly
Namespace
using System.Web.UI.HtmlControls;
C#
protected void Page_Load(object sender, EventArgs e)
{
HtmlGenericControl li = new HtmlGenericControl("li");
ulTabs.Controls.Add(li);
li.InnerText = "new menu";
HtmlGenericControl anchor = new HtmlGenericControl("a");
anchor.Attributes.Add("href", "page.htm");
anchor.InnerText = "TabX";
li.Controls.Add(anchor);
}
I am not getting what error you are having...