1
有沒有一種方法可以使用HtmlTextWriter創建這個?我想創建一個方法來創建HTML動態服務器端創建自定義HTML標籤Html TextWriter
<fieldset class='ui-grid-a' data-theme='c'>
這裏是關於代碼開始我不知道如何創建「數據主題」屬性,因爲沒有爲提供的枚舉..
// Initialize StringWriter instance.
StringWriter stringWriter = new StringWriter();
// Put HtmlTextWriter in using block because it needs to call Dispose.
using (HtmlTextWriter writer = new HtmlTextWriter(stringWriter))
{
foreach (string employee in myList)
{
writer.RenderBeginTag(HtmlTextWriterTag.Fieldset);
writer.AddAttribute(HtmlTextWriterAttribute.Class, "ui-grid-a");
writer.AddAttribute(HtmlTextWriterAttribute., "ui-grid-a");
}
}
你的意思是你想在ASP.NET中創建服務器端標記?! –
請記住,如果您創建自定義HTML「屬性」(這是您在問題中引用的而不是html標籤),則可能會創建無效的XHTML。檢查了這一點:http://stackoverflow.com/questions/1735230/can-i-add-custom-attribute-to-html-tag –