This article describes how to determine the correct setting for the DwpDataEncoded property on the Add Web Part task.
The DwpDataEncoded property on the Add Web Part task enables you to specify web part DWP data as either a raw string or a Base64-encoded string. The value you should set for this property depends on the format of the data in the DwpData property.
- If the value of the DwpData is a Base64-encoded string, set DwpDataEncoded to “True”.
- If the value of the DwpData property is a normal, non-Base64-encoded string, set
DwpDataEncoded to “false”.
To Base64-encode a string, you can use the following C# method:
public static string ConvertToBase64(string s)
{
byte[] sBytes = Encoding.Default.GetBytes(s);
return Convert.ToBase64String(sBytes);
}
The SharePoint SDK contains additional information about creating and adding web parts that may be helpful to you.