ASPxHtmlEditor.PastedImageSaving Event
Allows you to process and save the pasted binary image to the server.
Namespace: DevExpress.Web.ASPxHtmlEditor
Assembly: DevExpress.Web.ASPxHtmlEditor.v24.2.dll
NuGet Package: DevExpress.Web
#Declaration
public event PastedImageSavingEventHandler PastedImageSaving
#Event Data
The PastedImageSaving event's data class is PastedImageSavingEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Callback |
Gets or sets a string that contains specific information (if any) to be passed from the server side to the client.
Inherited from File |
Cancel |
Indicates if the action which raised the event should be canceled.
Inherited from File |
Error |
Gets or sets the error text.
Inherited from File |
File |
Gets or sets the name of the uploaded file.
Inherited from File |
Inner |
Gets or sets HTML content (inner HTML) that will be rendered inside the HTML tag specified in the Pasted |
Is |
Gets or sets a value specifying whether the uploaded file passes validation.
Inherited from File |
Output |
Set this property to change the original file content.
Inherited from File |
Saved |
Gets or sets the URL of the saved file.
Inherited from File |
Tag |
Gets or sets the root HTML element of the resulting HTML element. |
Uploaded |
Gets the uploaded file object related to the event.
Inherited from File |
The event data class exposes the following methods:
Method | Description |
---|---|
Set |
Specifies any attribute (including the data-* attributes) of the resulting HTML element. |
Set |
Specifies a CSS property in the ‘style’ attribute of the resulting HTML element. |
#Remarks
Handle the PastedImageSaving event to process the pasted binary image before it is saved to the server. This event also fires during the server side processing of the pasted RTF content in case it contains images. To process other images, video, and flash files before saving them to the server after uploading, handle the ASPxHtmlEditor.ImageFileSaving event (that fires after the PastedImageSaving event if the IsValid property is set to true
or the FileSavingEventArgs.Cancel property is set to false
).
Setting the IsValid property to false
and specifying the ErrorText property fires the client ASPxClientHtmlEditor.CallbackError event.
The following examples illustrate how to use the PastedImageSaving event to process and customize the pasted binary image.
Customized image styles
protected void ASPxHtmlEditor1_PastedImageSaving(object source, PastedImageSavingEventArgs e) { e.SetStyleAttribute("max-width", "100%"); e.SetStyleAttribute("border", "1px solid #aaa"); }
protected void ASPxHtmlEditor1_PastedImageSaving(object source, PastedImageSavingEventArgs e) { if (!e.IsValid) { e.SetAttribute("data-isvalid", "false"); e.SetAttribute("src", "broken-image.png"); e.SetAttribute("alt", "broken image"); } }
Changed render for the image element
protected void ASPxHtmlEditor1_PastedImageSaving(object source, PastedImageSavingEventArgs e) { if (!e.IsValid) { e.TagName = "DIV"; e.InnerHTML = "<img src='broken-image.png' />"; e.SetStyleAttribute("border", "1px dotted #f00"); } }
Note
The Pastedtrue
.