FileUploadCompleteEventArgs.CallbackData Property
Gets or sets a string that contains specific information (if any) to be passed from the server side to the client.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v22.2.dll
NuGet Package: DevExpress.Web
Declaration
Property Value
Type | Description |
---|---|
String | A String value representing callback data. |
Remarks
Use the CallbackData property to define specific information which has been collected on the server side, and should be passed to the client for further processing within the ASPxClientUploadControl.FileUploadComplete client event.
The example below demonstrates how to upload an image to the server and display the uploaded image on a web page:
<script type="text/javascript">
function OnFileUploadComplete(s, e) {
document.getElementById('image').src = e.callbackData;
}
</script>
<form id="form1" runat="server">
<div>
<dx:ASPxUploadControl ID="Upload" runat="server" ShowUploadButton="True" OnFileUploadComplete="Upload_FileUploadComplete">
<ValidationSettings AllowedFileExtensions=".jpg,.jpeg,.jpe,.gif">
</ValidationSettings>
<ClientSideEvents FileUploadComplete="OnFileUploadComplete" />
</dx:ASPxUploadControl>
<br />
<img src="Images/DefaultImage.jpg" id="image" alt="Please load image" />
</div>
</form>
protected void Upload_FileUploadComplete(object sender, FileUploadCompleteEventArgs e)
{
e.CallbackData = String.Format("Images\\Picture{0}.jpg", DateTime.Now.ToString("yyyy-MM-dd hh-mm-ss"));
string path = Page.MapPath("~/") + e.CallbackData;
e.UploadedFile.SaveAs(path);
}