GetResponseText Method

Retrieves a specified part of packaged downloaded data.

Cannot use methods in XAML.
retval = downloaderObject.GetResponseText(part)




The name of the specific part of the downloaded content package.

Return Value


The downloaded data. As in HTML, the return value can be examined and is passed as a string in a packet, but ultimately is interpreted by whatever property you set with this value.


You generally only call this method from within the event handler for a Downloader Completed event. Outside of this context, there is no guarantee that a GetResponseText return value is valid.

When a Downloader object request is completed, the GetResponseText method returns a representation of the downloaded content as a string value. The return value from GetResponseText can represent XAML content, JavaScript content, or a media asset, such as an image.

If you are not requesting parts of a package, and the Downloader request only returns a single asset, you typically would get the ResponseText property rather than GetResponseText. Calling GetResponseText with part value of "" gives the same value as ResponseText.

Note   If you are downloading media assets for use by the Source property of Image and MediaElement objects, you should consider using the SetSource (Image) or SetSource (MediaElement) methods rather than setting an object with GetResponseText or ResponseText and then setting the Source properties. This is a more efficient way to transfer large-sized media assets. ImageBrush also has an equivalent SetSource.

Silverlight provides the ability to download content as a package, which is a collection of independent files containing XAML content, media assets, and other application content. Once the package is successfully downloaded, you can use methods, such as GetResponseText, SetSource, and CreateFromXamlDownloader, to selectively retrieve a specific named part of the package. In this case, a part reference is the filename reference of the individual content within the package, such as "rotation01_green.png".

Retrieving a part from a download package

Retrieving a part from a download package

The part parameter of the GetResponseText method identifies the specific part to retrieve within the downloaded content.


The following JavaScript example shows how to use the GetResponseText method to retrieve a specified part from the downloaded content:

function onDownloadCompleted(sender, eventArgs)
    // Retrieve the XAML content from the downloaded package file.
    var jacketBrowserXaml = sender.getResponseText("jacketBrowser.xaml");
    // Create the objects from the XAML content.
    var jacketBrowser = plugin.content.createFromXaml(jacketBrowserXaml);
    // Add downloaded XAML content to the root Canvas of the plug-in.
    sender.findName("root").children.insert(0, jacketBrowser);
    // Retrieve a reference to the Image object representing the jacket.
    var jacketImageSlice = sender.findName("jacketSlice");
    // Set the Source property of the Image object to the specific jacket image
    // within the downloaded Zip package file.
    jacketImageSlice.setSource(sender, "rotation01_green.png");

Applies To


See Also

Using a Downloader Object
SetSource (MediaElement)