Serialize GenericWebPart
Hej e.Er her en som kan vise min hvordan man kan Serialize System.Web.UI.WebControls.WebParts.GenericWebPart.
Her er den kode del jeg vil benytte den i:
var WebParts = new List<TemplateWebPart>();
foreach(WebPart wp in WebPartZoneBase.WebParts)
{
var x = new XmlSerializer(wp.GetType());
var _webpart = new TemplateWebPart();
_webpart.WebpartID = wp.ID;
_webpart.WebpartType = webpart.GetType();
_webpart.WebpartPropertys = x.ToString();
WebParts.Add(_webpart);
}
Men denne fejler:
var x = new XmlSerializer(wp.GetType());
og her er fejlen:
System.Web.UI.WebControls.WebParts.GenericWebPart cannot be serialized because it does not have a parameterless constructor.