GenoPro Developer Home
GenoPro Home  |  SDK Home  |  Report Generator  |  Support  |  Search  |  Help  |  Site Map

Skip Navigation Links.

Util.HtmlEncode Method

The HtmlEncode method applies HTML encoding to a string to prevent a special character to be interpreted as an HTML tag. This method is useful for displaying text that may contain "special" HTML characters such as quotes, angle brackets and other characters by the HTML language. This is the equivalent of Server.HtmlEncode in ASP.

Character Converted To
"  {double quote} "
'  {apostrophe / single quote } ' 1
& &
< &lt;
> &gt;
{space} &nbsp; 2
{tab} &nbsp;&nbsp;&nbsp;&nbsp;
{return} / {linefeed} <br /> 3

1. The apostrophe should be encoded to the entity &apos; however Internet Explorer does not recognize this entity. As a result, the apostrophe is encoded using its numeric code point #39.
2. A Single space is not coded to the entity &nbsp;. If more than one consecutive space is encountered, then all spaces after the first space character are converted to &nbsp;.
3. Any carriage return - linefeed (CRLF) combination is converted to a single HTML <br /> tag. Thus a {return-linefeed} sequence is converted to <br />, but a {return}{return} sequence is converted to <br /><br />. For compatibility with existing browser, the Break tag is written as <br /> rather than <br/> or <br>. Most browser will accept all three forms, however some web browsers may not like the <br/> tag. The <br> tag is not recommended because it is not XML/XHTML compatible.

Usage:
You should use the HtmlEncode method each time you want to display text from the genealogy tree such as a name, comment or any other data field. The HtmlEncode method may be used to create HTML hyperlinks.

strName = Util.HtmlEncode(i.name)
Report.Write strName

Tip:
The report generator has the method Report.WriteText(str) method which does the HTML encoding automatically.

See Also:
HtmlDecode
FormatString /w {&t} encoding
Report.WriteText

 

Copyright ┬ę 1998-2014. All rights reserved. GenoPro┬« and the GenoPro logo are registered trademarks.