corelibraries-devexpress-dot-data-dot-asyncdownloadpolicy-dot-downloadingeventargs-54417c7a.md
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.v25.2.dll
NuGet Package : DevExpress.Data
public Type ValueType { get; }
Public ReadOnly Property ValueType As Type
| Type | Description |
|---|---|
| Type |
Result type.
|
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 */);
}
Public Sub New()
InitializeComponent()
AddHandler AsyncDownloadPolicy.Downloading, AddressOf AsyncDownloadPolicy_Downloading
End Sub
Private whitelist As New Dictionary(Of Integer, String)() From {
{ 0, "www.devexpress.com" },
{ 1, "community.devexpress.com" },
{ 2, "docs.devexpress.com" },
{ 3, "supportcenter.devexpress.com" }
}
Private Sub AsyncDownloadPolicy_Downloading(ByVal sender As Object, ByVal e As AsyncDownloadPolicy.DownloadingEventArgs)
Dim result As String = e.ValueType.Name
' Checks whether a picture editor initiated the download.
If result = "ImageOrSvgImageResult" Then
' Cancels downloading from domains that are not in the whitelist.
e.Cancel = Not whitelist.Values.Contains(e.Uri.Authority)
End If
End Sub
Private Sub loadImageButton_Click(ByVal sender As Object, ByVal e As EventArgs)
pictureEdit1.LoadAsync("YOUR_URL")
End Sub
Read the following topic for detailed information: Suppress Control Requests to Download Data from External URLs.
See Also
AsyncDownloadPolicy.DownloadingEventArgs Class