Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

DataPackage.SetHtmlFormat | setHtmlFormat method

Applies to Windows and Windows Phone

Adds HTML content to the DataPackage.

Syntax


dataPackage.setHtmlFormat(value);

Parameters

value

Type: String [JavaScript] | System.String [.NET] | Platform::String [C++]

The HTML content.

Remarks

To ensure that a target app can process the HTML content, use HtmlFormatHelper.CreateHtmlFormat. It adds the required headers and other information the string containing the HTML.

If your app supports selection or copying/pasting of HTML content that contains img elements, be sure that the src attributes specify fully-qualified absolute paths to the images, not relative paths.

Examples


function shareHtmlHandler(e) {
    var request = e.request;
    var htmlExample = "<p>Here is our store logo: <img src='images/logo.png'>.</p>";
    var localImage = "images\\logo.png";
    request.data.properties.title = "Share Html Example";
    request.data.properties.description = "A demonstration that shows how to share an HTML fragment with a local image.";
    var deferral = e.request.getDeferral();
    Windows.ApplicationModel.Package.current.installedLocation.getFileAsync(localImage).done(function (imageFile) {
        request.data.setHtmlFormat(Windows.ApplicationModel.DataTransfer.HtmlFormatHelper.createHtmlFormat(htmlExample));
        request.data.resourceMap[localImage] = Windows.Storage.Streams.RandomAccessStreamReference.createFromFile(imageFile);
        deferral.complete();
    }, function (err) {
        request.failWithDisplayText(err);
    });
}


Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.ApplicationModel.DataTransfer
Windows::ApplicationModel::DataTransfer [C++]

Metadata

Windows.winmd

See also

DataPackage

 

 

Show:
© 2014 Microsoft