RichEditBuilder.OnBeforeSend(String) Method
Specifies a function used to customize a web request before it is sent to an action handler.
Namespace: DevExpress.AspNetCore.RichEdit
Assembly: DevExpress.AspNetCore.RichEdit.v25.1.dll
NuGet Package: DevExpress.AspNetCore.RichEdit
Declaration
public RichEditBuilder OnBeforeSend(
string callback
)
Parameters
| Name | Type | Description |
|---|---|---|
| callback | String | A JavaScript function. |
Returns
| Type | Description |
|---|---|
| RichEditBuilder | A reference to this instance after the method is called. |
Remarks
Use this method to register a client-side handler for the Rich Text Editor control’s beforeSend event. The handler can be a reference to an external function or an inline function text:
<script>
function richEdit_beforeSend(richEdit, e) {
/* ... */
}
</script>
@(Html.DevExpress().RichEdit("richEdit")
.ExportUrl(Url.Page(pageName: null, pageHandler: "DxRichEditExport"))
.OnBeforeSend("richEdit_beforeSend")
)
The function receives the following arguments:
- The client-side Rich Text Editor object instance.
- An object that contains event arguments. Use the object’s
requestproperty to access and modify the underlying XMLHttpRequest (for example, add headers).
The following code snippet adds an anti‑forgery token to every internal request the Rich Text Editor sends to the request handler (controller action):
@inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Antiforgery
<script>
function richEdit_beforeSend(richEdit, e) {
e.request.setRequestHeader("RequestVerificationToken",
"@Antiforgery.GetAndStoreTokens(HttpContext).RequestToken");
}
</script>
@(Html.DevExpress().RichEdit("richEdit")
.ExportUrl(Url.Page(pageName: null, pageHandler: "DxRichEditExport"))
.OnBeforeSend("richEdit_beforeSend")
)
See Also