HtmlFormatHelper.CreateHtmlFormat | createHtmlFormat method

Applies to Windows and Windows Phone

Takes a string that represents HTML content and adds the necessary headers to ensure it is formatted correctly for share and Clipboard operations.

Syntax

Public Shared Function CreateHtmlFormat(
  htmlFragment As String 
) As String

Parameters

htmlFragment

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

A string representing the HTML content.

Return value

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

A string representing the formatted HTML.

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 Runtime apps only]

Namespace

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

Metadata

Windows.winmd

See also

HtmlFormatHelper

 

 

Show:
© 2014 Microsoft