C# extension methods for the HtmlTextWriter class.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Web.UI;
namespace Extensions
{
public static class HtmlTextWriterExtensions
{
public static void AddAttributes(this HtmlTextWriter writer, IDictionary<string, object> attributes)
{
if (attributes.Any<KeyValuePair<string, object>>())
{
foreach (KeyValuePair<string, object> attribute in attributes)
{
writer.AddAttribute(attribute.Key, attribute.Value.ToString(), true);
}
}
}
}
}