Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1810
WebDatePicker + PersistenceFramework + Culture
posted

Hi,

We are having some trouble serializing a WebDatePicker on a server and deserializing it on another one where Culture is different (or even if it is the same server but Culture used on deserialization depends on the web client).

Desrialization fails with "String was not recognized as a valid DateTime."

Is this the expected behavior?

Thanks.

Here is how you can reproduce this issue:

protected void Page_Load(object sender, EventArgs e)

{
if (!Page.IsPostBack)
{
 PersistenceManager lManager = PersistenceManager.GetInstance();
MemoryStream lSTream = (MemoryStream)GetDatePicker();
lSTream.Position = 0;
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("es-UY");
PersistenceData lData = PersistenceData.FromStream(lSTream);
var lControl = new WebDatePicker();
lManager.LoadControl(lControl, lData.Controls[0]);
PlaceHolder1.Controls.Add(lControl);

}
}

public Stream GetDatePicker(){
WebDatePicker lDatePicker = new WebDatePicker();
lDatePicker.BackColor = System.Drawing.Color.Red;
lDatePicker.Value = new DateTime(2012, 12, 21);

Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("en-US");

PersistenceManager lManager = PersistenceManager.GetInstance();
PersistenceData lData = new PersistenceData();
lData.Controls.Add(lManager.SaveControl(lDatePicker, "control"));
return lData.ToStream();
}