Exemple #1
0
 /// <summary>
 /// Obtains the serialized result message that will be used in the client side
 /// </summary>
 /// <returns> A JSON object</returns>
 public string GetCallbackResult()
 {
     if (callbackEventException == null)
     {
         validator.Validate();
         ServerValidationResults    results = new ServerValidationResults(this.valueToValidate, validator.IsValid, validator.ErrorMessage);
         DataContractJsonSerializer ser     = new DataContractJsonSerializer(typeof(ServerValidationResults));
         MemoryStream ms = new MemoryStream();
         ser.WriteObject(ms, results);
         string serialized = Encoding.Default.GetString(ms.ToArray());
         ms.Close();
         return(serialized);
     }
     else
     {
         throw callbackEventException;
     }
 }
Exemple #2
0
        /// <summary>
        /// Implementation of a Callback event.
        /// </summary>
        /// <param name="eventArgument"> The argument of the event</param>
        public void RaiseCallbackEvent(string eventArgument)
        {
            try
            {
                DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ServerValidationResults));
                MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(eventArgument));

                ServerValidationResults arguments = ser.ReadObject(ms) as ServerValidationResults;
                this.valueToValidate = arguments.Value;

                this.validator = GetExtendedValidator();
                SetControlValidationValue(validator, validator.ControlToValidate, this.valueToValidate);
            }
            catch (Exception ex)
            {
                callbackEventException = ex;
            }
        }