Reputation: 8188
Is there a way to create this using HtmlTextWriter? I am trying to create a method to create html dynamically server-side
<fieldset class='ui-grid-a' data-theme='c'>
Here is a start on the code I am not sure how to create the "data-theme" attribute because there is no enum offered for that..
// 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");
}
}
Upvotes: 1
Views: 819
Reputation: 4083
Regarding the comment: Here is a start on the code I am not sure how to create the "data-theme" attribute because there is no enum offered for that..
Do not use the overload that only takes the enum and instead the overload that accepts two string values: http://msdn.microsoft.com/en-us/library/985bhaz6.aspx
e.g.
writer.AddAttribute("data-theme", "c");
Upvotes: 4