public bool TryLoadEventValidationField(object eventValidationField) { EventValidationStore validatedIncomingEvents = eventValidationField as EventValidationStore; if (validatedIncomingEvents == null || validatedIncomingEvents.Count < 1) { return true; // empty collection is not an error condition } Debug.Assert(_outboundEvents == null); string viewStateString = _clientScriptManager._owner.RequestViewStateString; if (!validatedIncomingEvents.Contains(null, viewStateString)) { return false; // error: this event validation store isn't associated with the incoming __VIEWSTATE } _inboundEvents = validatedIncomingEvents; if (_clientScriptManager._owner.IsCallback) { // Seed the outbound provider with the valid inbound values; clone so that any outbound values // added during page processing aren't accidentally treated as valid inbound values. EventValidationStore clonedEventValidationStore = validatedIncomingEvents.Clone(); _outboundEvents = clonedEventValidationStore; } return true; }
public void RegisterForEventValidation(string uniqueId, string argument) { if (_outboundEvents == null) { if (_clientScriptManager._owner.IsCallback) { _clientScriptManager.EnsureEventValidationFieldLoaded(); // _outboundEvents could have been initialized by the call to EnsureEventValidationFieldLoaded. if (_outboundEvents == null) { _outboundEvents = new EventValidationStore(); } } else { // Make a new store object and tie it to the outbound __VIEWSTATE field. // (This is the only field which can have a null/empty 'target'.) _outboundEvents = new EventValidationStore(); _outboundEvents.Add(null, _clientScriptManager._owner.ClientState); } } _outboundEvents.Add(uniqueId, argument); }