IMSCSPage_3_0::HTMLEncode

Ee797278.c++_off(en-US,CS.10).gifEe797278.vb_on(en-US,CS.10).gif

Use this method to apply HTML encoding to the specified text string. Its typical use is to display the contents of text fields contained in the database in HTML. Characters in the string, such as "<" and "&" that have special meanings in HTML, are converted into their HTML equivalents, such as &lt; and &amp; so that they will be displayed correctly by the client browser.

Ee797278.important(en-US,CS.10).gif Important

  • This method is included for backwards compatibility with Site Server 3.0 Commerce Edition.

Definition

HRESULT IMSCSPage_3_0::HTMLEncode(VARIANTvtValue,BSTR*pbstrRet);

Parameters

vtValue

[in] A VARIANT that contains the text string to encode.

pbstrRet

[out, retval] A pointer to a BSTR used to return the encoded HTML text.

Return Values

This method returns an HRESULT indicating whether or not it completed successfully. See the Error Values section for more details.

Error Values

This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

Remarks

The pbstrRet parameter points to valid data only if the method completed successfully.

If the text field to be displayed already contains HTML encoding, do not use the HTMLEncode method. For example, suppose your product_description field contains HTML-encoded text such as "The <I>Classic Diner Clock</I> brings the age of the &quot;Golden Oldies&quot; to your kitchen." This string uses the <I> tag to format italic text and the &quot; sequence to display quotation marks when displayed by the client browser. Because the string is already coded in HTML, you do not need to encode it again. Double-encoding the string would produce incorrect results.

The Page.HTMLEncode method is identical to the Page.Encode method, but the HTMLEncode method is the preferred name. The method is similar to Server.HTMLEncode except that the Page.HTMLEncode method handles NULL values by returning an empty string (the Server.HTMLEncode method fails when the vtValue parameter is NULL). This distinction is important because database queries can return NULL.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

See Also

Page Object

IMSCSPage_3_0::URLEncode


All rights reserved.