In order to better manage the size and performance of some of our larger listx implementations, we've relegated some forms to DB entries outside of the listx xml setting. These forms are of standard HTML but with inline listx tags such as Action script query references like [column,query], Session, Action and Form variable tags like [name[*ModuleID],Session], and query variable targets as well as {ACTION,value,name,Type} actions. These can all be embedded within the form text un-escaped. The form is retrieved using a SELECT query from within the Action scripts list. You can SELECT it from within the query select list as well, although it’s too late in the process to replace query variable targets here. That's basically it for the retrieval side. It takes a little bit of footwork however, to author these forms using listx like we are - you must handle the reserved characters [] and {}. In three areas we encode the form text, 1. to populate the textarea, 2. to write the text to the db and 3. to post the text back through lisx. The encoded text exists only during the trip to and from its destinations - the screen and the db. Note that the encode characters are not stored in the db. 1. Presenting the text into the textarea. We SELECT the form from within the query list items. The SELECTED content requires the following SQL REPLACE logic and includes encoded text for "<" & ">" to handle the textarea HTML tags.<Pre> Just the column (Content ntext): Replace(Replace(Replace(Replace(Replace(Replace(CAST(Content as varchar(8000)),'[','['),']',']'),'{','{'),'}','}'),'>','>'),'<','<') Code including the textarea: SELECT EncapsulatedContent = '<textarea id=frmContent name=frmContent style="width:100%; height: 400px;" rows=40>' + Replace(Replace(Replace(Replace(Replace(Replace(CAST(Content as varchar(8000)),'[','['),']',']'),'{','{'),'}','}'),'>','>'),'<','<') + '</textarea>'</PRE> 2. We write the text to the db in the Actions script list and the reverse REPLACE is done but minus the encoding for the textarea tags. [myContent] is an escaped() query variable target.<PRE> Set Content = Replace(Replace(Replace(Replace('[myContent]','[','['),']',']'),'{','{'),'}','}') Now, for the final piece. 3. The [] & {} characters must be escaped before the form post’s, so it’s JavaScript to the rescue. I'm no expert in this area but it works. There are a couple of things to note. <PRE> <textarea id="EncapContent" name="EncapContent" style="Position:absolute; left:-3000; z-index:1000; visibility:hidden;" ></textarea> <script type="text/javascript"> function EncapForm() { var theform; var s; if (window.navigator.appName.toLowerCase().indexOf("microsoft") > -1) { theform = document.Form; } else { theform = document.forms["Form"]; } s = theform.frmContent.value; s = s.replace("\[","["); s = s.replace(/\\[/g,"["); s = s.replace(/\\]/g,"]"); s = s.replace(/\\{/g,"{"); theform.EncapContent.value = s.replace(/\\}/g,"}"); return true; } </script> </Pre> For some reason I could not get the regex replace to work without starting off with a dummy replace statement "s = s.replace("\[","[");". This does nothing except to allow the subsequent replace statements to work. I demonstrated the same behavior in both Fire Fox and IE. The [] & {} are reserved characters for both regex and listx, so perhaps some contention is taking place. theform.frmContent.value holds the client text. I call an encode function that encapsulates the text string and writes it to a different and invisible textarea. If we write the encoded result back to theform.frmContent.value and submit it, you will briefly see the encoded text displayed in the textarea just prior to your post. I didn't like this behavior, therefore I write the text to be sent to another textarea and have listx process it instead. It makes for a better experience. Notice the double backslash before the reserved characters in the regex strings. This is so listx does not process the regular expression. If you chose to use FreeTextBox you would have to apply a similar encapsulation method. I have not performed exhaustive testing on this method nor have I made it robust. I hope you find it useful. Your comments and improvements are welcome. Mike |