Dynamic content and State attribute
I had a problem with the State attribute. This is the attribute that is saved inside the span [SPAN class=dynamiccontent contentEditable=false style="....." disabled hash="oqAE..zt1Y=" state="xxx"][/SPAN]
I tried to save some xml inside it, and the dynamic content render just wouldnt save. it seems like the attribute can contains html/xml tags.
The trick was to convert my string into Base64.
public string Value;#region Value64
public string Value64
{
get
{
if (Value == null)
return null;
return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes((string)Value));
}
set
{
if (value != null)
{
byte[] toDecodeByte = Convert.FromBase64String(value);
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
int charCount = utf8Decode.GetCharCount(toDecodeByte, 0, toDecodeByte.Length);
char[] decodedChar = new char[charCount];
utf8Decode.GetChars(toDecodeByte, 0, toDecodeByte.Length, decodedChar, 0);
string result = new String(decodedChar);
Value = result;
}
}
}
#endregion
#region State (64)
public string State
{
get
{
return Value64;
}
set
{
Value64 = value;
}
}
#endregion
Comments