Does anybody knows if it is necessary to sanitize the contents of the HtmlControl.Attributes? MSDN is silent in that:
http://msdn.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlcontrol.attributes.aspx
In other words, which of this is correct:
HtmlGenericControl control = new HtmlGenericControl();
/*Option 1*/ control.Attributes["value"] = HttpUtility.HtmlAttributeEncode(unsafestring);
/*Option 2*/ control.Attributes["value"] = unsafestring;