AsyncDownloadPolicy.DownloadingEventArgs.ValueType Property
Gets a value that identifies the group of controls to which an individual control (that initiated the download) belongs.
Namespace: DevExpress.Data
Assembly: DevExpress.Data.v24.1.dll
NuGet Package: DevExpress.Data
Declaration
Property Value
Type | Description |
---|---|
Type | Result type. |
Remarks
Different DevExpress UI components with the same functionality (for example, separate WinForms PictureEdit controls that load images from URI paths) utilize the same HttpClient
. As a result, the event’s e.ValueType
parameter is the same for all individual controls (for aforementioned PictureEdit
controls, e.ValueType
returns ImageOrSvgImageResult
). This technique allows you to identify the group of controls to which an individual control (that initiated the download) belongs.
public Form1() {
InitializeComponent();
AsyncDownloadPolicy.Downloading += AsyncDownloadPolicy_Downloading;
}
Dictionary<int, string> whitelist = new Dictionary<int, string>() {
{ 0, "www.devexpress.com" },
{ 1, "community.devexpress.com" },
{ 2, "docs.devexpress.com" },
{ 3, "supportcenter.devexpress.com" }
};
private void AsyncDownloadPolicy_Downloading(object sender, AsyncDownloadPolicy.DownloadingEventArgs e) {
string result = e.ValueType.Name;
// Checks whether a picture editor initiated the download.
if(result == "ImageOrSvgImageResult")
// Cancels downloading from domains that are not in the whitelist.
e.Cancel = !whitelist.Values.Contains(e.Uri.Authority);
}
private void loadImageButton_Click(object sender, EventArgs e) {
pictureEdit1.LoadAsync(/* YOUR_URL */);
}
Read the following topic for detailed information: Suppress Control Requests to Download Data from External URLs.