CodeCarvings Piczard V1.2 Help
PopupPictureTrimmer - Server-side events
Send Feedback
Piczard Fundamentals - Web > PictureTrimmer > PopupPictureTrimmer > PopupPictureTrimmer - Server-side events

Glossary Item Box

CONTENTS

  1. The ValueChanged event handler
  2. The PopupClose event handler

Please see the Example A.322 - "Web - PictureTrimmer / PopupPictureTrimmer - Server side events"

 

 

1. The ValueChanged event handler

The ValueChanged event allows the application to intercept changes to the Value property (made by the end-user on the client-side).
This server-side event is raised only after a page postback.

Differently from the InlinePictureTrimmer control, the PopupPictureTrimmer control allows to generate autmatic postbacks when the user closes the popup window.
Please see: AutoPostBackOnPopupClose

The event argument PictureTrimmerValueChangedEventArgs (passed as a parameter to the PictureTrimmerValueChangedEventHandler delegate) provides access to:

In this way you can understand what has been changed by the user.

Example:

Copy Code
protected void PopupPictureTrimmer1_ValueChanged(object sender, PictureTrimmerValueChangedEventArgs e)
{
   
if (e.NewValue.ImageSelection.Transformation.ResizeFactor != e.PreviousValue.ImageSelection.Transformation.ResizeFactor)
   {
       Response.Write(
"Reisze factor has been changed");
   }
   
if (e.NewValue.ImageSelection.Crop.Rectangle.Value.Width != e.PreviousValue.ImageSelection.Crop.Rectangle.Value.Width)
   {
       Response.Write(
"Width of the crop rectangle has been changed");
   }
   
if (e.NewValue.ImageAdjustments.Brightness != e.PreviousValue.ImageAdjustments.Brightness)
   {
       Response.Write(
"Brightness has been changed");
   }
}

The ValueChanged event is raised only if the value (PictureTrimmerValue) of the PictureTrimmer control has been changed.
This event is not raised if the users changes one of the properties of the UI parameters (e.g. the ZoomFactor).

If you need to intercept every change to the state of the control (PictureTrimmerUserState - for example PictureScrollH) then you have to use the "UserStateChanged" client-side event handler.
Please see: PopupPictureTrimmer - Client-side events

 

 

2. The PopupClose event handler

The PopupClose event allows the application to intercept (on the server-side) the event generated when the user closes the popup window on the client-side.

This event is raised only after a page postback.
For this reason, the control provides the property AutoPostBackOnPopupClose that allows to automatically raise a page postback when the popup window is closed.

The event argument PictureTrimmerValueChangedEventArgs (passed as a parameter to the PictureTrimmerPopupCloseEventHandler delegate) can be used to undestand if the user has closed the popup by clicking the "Save" button - or - by clicking the "Cancel" button.

Example:

Copy Code
protected void PopupPictureTrimmer1_PopupClose(object sender, PictureTrimmerPopupCloseEventArgs e)
{
   
if (e.SaveChanges)
   {
       Response.Write(
"Popup closed - The new selected width is " + PopupPictureTrimmer1.Value.ImageSelection.Crop.Rectangle.Value.Width);
   }
   
else
   {
       
Response.Write("Popup closed - the changes have been cancelled");
   }
}

Differently from the ValueChanged event handler, the PopupClose event handler does not provide access to the previous value of the control.
If you need access to the previous value, then you have to use the ValueChanged event handler.

The PopupClose event is raised after the ValueChanged event.

 

©2013 Sergio Turolla. All Rights Reserved.