| ASPWith Active Server Pages or other server side technologies like .NET or ColdFusion, it is possible to write a function that simply creates a HTML Rich Text Area with one line of code. This is useful because it is simple to use and if you want to modify the way a HTML Rich Text Area is displayed then code need only be changed in one place. All of the ASP code necessary to display a HTML Rich Text Area can be found in the inc/HTMLRichTextArea.asp file. This can be incorporated into your existing web site via a server side include (i.e. <!-- #include file="/inc/HTMLRichTextArea.asp" -->) or by simply copying and pasting the code into your web site's existing code library. The ASP code automatically ensures that the HTMLRichTextArea.js is only included once per web page and that all characters that interfere with javascript's syntax are escaped using a backslash (\). e.g. Javascript delimits strings by using the apostrophe ('). If the default string also includes an apostrophe then a javascript syntax error will occur as it will have prematurely found the string delimiter. The ASP code avoids these issues by escaping apostrophes, carriage return and line feeds and the escape character (\). To display a HTML Rich Text Area using the supplied ASP code do the following: Response.Write(DisplayHTMLRTA("MyHTMLRTA","<h1>Test</h1>This is a test web page", "../inc/", 80,200)) An example of this output is seen below in which all of the ASP's functionality has been exercised. DisplayHTMLRTA accepts the following parameters:
The ASP code generates a javascript variable called htmlrta[strName] that references the HTML Rich Text Area. e.g. If strName was passed in as 'Email' then a javascript variable is available called 'htmlrtaEmail'. This means that the HTML Rich Text Area's programmatic interface is available through javascript. <%... Response.Write(DisplayHTMLRTA("Demo",strText,"../../inc/HTMLRTA/",80,300)) %> <input type="button" onclick="ChangeReadOnlyState()" value="Toggle Read Only"> <script LANGUAGE="javascript"> <!-- var blnReadOnly = false; function ChangeReadOnlyState() { blnReadOnly = !blnReadOnly; htmlrtaDemo.MakeReadOnly(blnReadOnly); } //--> </script>; For completeness the code found in HTMLRichTextArea.asp is displayed below. Be sure to edit this code to suit your environment. |
|