If I try to deserialize it again I'm getting an error because it's not real xml. Any idea what goes wrong here? I'm using Umbraco 4.7.2. I looked at the value which is returned from HiddenVoteValue.Value, but it's not encoded or something.
I marked your post as the solution because it pointed me in the right direction. This is my code now:
public partial class VoteFormViewer : BaseUserControl, IUsercontrolDataEditor
{
#region Properties
#region IUsercontrolDataEditor Members
public object value
{
get
{
return ViewState["VoteValue"];
}
set
{
Vote vote = new Vote();
ViewState["VoteValue"] = SerializationHelper.ValueToXmlString(vote);
}
}
#endregion
#endregion
protected void Page_Load(object sender, EventArgs e)
{
}
}
Because the HiddenVoteValue.Value (or ViewState which I'm using now) is already a string I don't need to use the SerializationHelper.ValueToXmlString. Thanks for helping!
A little more info about this might be useful. I'm tryin to create a datatype which only shows data in the datatype with the option to export. So in the set I need to do some stuff to display the data and in the get only return that same data again because it can't be changed in Umbraco. That's why the viewstate is fine. The data will be changed on the front of the website with the Umbraco Document api.
Parseable xml with usercontrolwrapper not working
Hello,
I working on a custom datatype. For now I'm only trying to store a custom object in the xml, but it's not stored as real xml. Here is the code:
VoteFormViewer.ascx
VoteFormViewer.ascx.cs
Here is the test class I'm trying to serialize in xml:
This is the xml I'm getting in the Umbraco.config:
If I try to deserialize it again I'm getting an error because it's not real xml. Any idea what goes wrong here? I'm using Umbraco 4.7.2. I looked at the value which is returned from HiddenVoteValue.Value, but it's not encoded or something.
Jeroen
Most probably because of ntext vs nvarchar storage of your datatype value! Have had this before...
/Dirk
I'm storing it as ntext because nvarch is too short.
Jeroen
I've been using this blog as a reference: http://www.nibble.be/?p=100
Jeroen
Comment author was deleted
Hey Jeroen,
in your getter you are serializing the HiddenVoteValue.Value and that will be a string... you should feed it an object of type vote
Comment author was deleted
In the example on my blog the customControl.Value is of type List<string>
Hi Tim,
I marked your post as the solution because it pointed me in the right direction. This is my code now:
Because the HiddenVoteValue.Value (or ViewState which I'm using now) is already a string I don't need to use the SerializationHelper.ValueToXmlString. Thanks for helping!
Jeroen
Comment author was deleted
So should be more like
A little more info about this might be useful. I'm tryin to create a datatype which only shows data in the datatype with the option to export. So in the set I need to do some stuff to display the data and in the get only return that same data again because it can't be changed in Umbraco. That's why the viewstate is fine. The data will be changed on the front of the website with the Umbraco Document api.
Jeroen
is working on a reply...