Export (0) Print
Expand All

Uri Property

Gets the Uniform Resource Identifier (URI) of the download request.

XAML
Cannot be used in XAML.
Scripting
value = downloaderObject.Uri

Property Value

string

A string value that corresponds to the URI of the Downloader object request.

This property is read-only. The default value is an empty string.

Remarks

When you invoke the Send method of the Downloader object, you specify a uri parameter that represents the data to be downloaded. The Uri property corresponds to the value of the uri parameter of the Send method. The Uri property enables you to differentiate downloaded content when you use the share DownloadProgressChanged or Completed event handler functions for multiple Downloader object requests.

Note   The Uri value must reference a file that comes from the same site of origin as the instantiated Silverlight plug-in. Usually this is accomplished by specifying a relative URI.

Examples

The following JavaScript example shows how to use the Uri property in a Completed event handler function to determine what actions to take for the returned value of the GetResponseText method invocations. Since the downloaded content does not represent packaged content, the part parameter for GetResponseText must be set to an empty string. Notice that the Status property value is used to determine whether the content was successfully downloaded:

JavaScript
// Event handler for the Completed event.
function onCompleted(sender, eventArgs)
{
    // If HTTP status code indicates "OK", determine action based on URI property.
    if (sender.uri == "OK_button.js")
    {
        // Evaluate JavaScript code -- causes code to be memory-resident.
        eval(sender.ResponseText);
    }

    if (sender.uri == "OK_button.xaml")
    {
        // Retrieve downloaded XAML content.
        var xamlFragment = sender.ResponseText;

        // Create the objects from the XAML content.
        var plugin = sender.getHost();
        var button = plugin.content.createFromXaml(xamlFragment);

        // Add downloaded XAML content to the root Canvas of the plug-in.
        var rootCanvas = sender.findName("rootCanvas");
        rootCanvas.children.add(button);
    }
}

Applies To

Downloader

See Also

Using a Downloader Object
Completed
DownloadProgressChanged
Send
Status

Community Additions

Show:
© 2014 Microsoft