Export (0) Print
Expand All

Open

Silverlight

Initializes a download request.

downloaderObject.Open(verb, uri)

verb

string

The type of download action. The only supported action is "GET".

uri

string

The Uniform Resource Identifier (URI) of the content to be downloaded.

Managed programming does not use Downloader. See WebClient.

The Open method initializes the Downloader object by specifying the action to perform and the content to perform the action on. However, the download is not committed until you call the Send method.

The uri parameter must reference content on the same site as the hosting HTML page. Cross-domain downloads are not permitted with the Downloader object. Also, backslashes (\) in Downloader URIs are not permitted; always use forward slashes (/). Generally, it is best to use relative URIs, which are calculated based on the position of the hosting HTML page.

The following JavaScript example shows how to call the Open method.

// Event handler for initializing and executing a download request.
function onMouseLeftButtonUp(sender, eventArgs)
{
    // Retrieve a reference to the plug-in.
    var slPlugin = sender.getHost();

    // Create a Downloader object.
    var downloader = slPlugin.createObject("downloader");

    // Add DownloadProgressChanged and Completed events.
    downloader.addEventListener("downloadProgressChanged", onDownloadProgressChanged);
    downloader.addEventListener("completed", onCompleted);

    // Initialize the Downloader request.
    // Note: Downloader APIs disallow file:\\ scheme.
    // You must run this sample over localhost: or off a server; otherwise, the following call will fail.

    downloader.open("GET", "promo.png");

    // Execute the Downloader request.
    downloader.send();
}

Community Additions

ADD
Show:
© 2014 Microsoft