/// <summary> /// Default constructor /// </summary> public TimeSpanInputBoxExtender() { this.EnableClientState = true; this.state = new TimeSpanInputClientState(); this.value = new NhsTimeSpan(); this.ClientStateValuesLoaded += new EventHandler(this.TimeSpanInputBoxExtender_ClientStateValuesLoaded); }
/// <summary> /// Handle loading of client state /// </summary> /// <param name="sender">sender</param> /// <param name="e">args</param> private void TimeSpanInputBoxExtender_ClientStateValuesLoaded(object sender, EventArgs e) { if (this.ClientState != null) { // this.state = new JavaScriptSerializer().Deserialize<TimeSpanInputClientState>(ClientState); // this.Value.From = DateTime.Parse(this.state.From, CultureInfo.CurrentCulture); // this.Value.Granularity = (TimeSpanUnit)this.state.Granularity; // this.Value.IsAge = (bool)this.state.IsAge; // this.text = this.state.Text; // this.Value.To = DateTime.Parse(this.state.To, CultureInfo.CurrentCulture); // this.Value.Threshold = (TimeSpanUnit)this.state.Threshold; // this.value = (NhsTimeSpan)this.state.Value; JavaScriptSerializer jss = new JavaScriptSerializer(); jss.RegisterConverters(new JavaScriptConverter[] { new NhsTimeSpanJavascriptConverter() }); this.state = jss.Deserialize <TimeSpanInputClientState>(ClientState); this.value = this.state.Value; this.unitLength = (TimeSpanUnitLength)this.state.UnitLength; } }
/// <summary> /// Handle loading of client state /// </summary> /// <param name="sender">sender</param> /// <param name="e">args</param> private void TimeSpanInputBoxExtender_ClientStateValuesLoaded(object sender, EventArgs e) { if (this.ClientState != null) { // this.state = new JavaScriptSerializer().Deserialize<TimeSpanInputClientState>(ClientState); // this.Value.From = DateTime.Parse(this.state.From, CultureInfo.CurrentCulture); // this.Value.Granularity = (TimeSpanUnit)this.state.Granularity; // this.Value.IsAge = (bool)this.state.IsAge; // this.text = this.state.Text; // this.Value.To = DateTime.Parse(this.state.To, CultureInfo.CurrentCulture); // this.Value.Threshold = (TimeSpanUnit)this.state.Threshold; // this.value = (NhsTimeSpan)this.state.Value; JavaScriptSerializer jss = new JavaScriptSerializer(); jss.RegisterConverters(new JavaScriptConverter[] { new NhsTimeSpanJavascriptConverter() }); this.state = jss.Deserialize<TimeSpanInputClientState>(ClientState); this.value = this.state.Value; this.unitLength = (TimeSpanUnitLength)this.state.UnitLength; } }