Pages

Thursday, May 8, 2014

Rendertag to Escape Double Quote and Single Quote

This is a solution posted by Tim Davis on https://groups.google.com/forum/#!topic/reddot-cms-users/ImqWdAN4XIY

You want to assign text placeholder content class a server side preexecution variable, but the text placeholder contains double quote, single quote and carriage return, which will cause preexecution error because the resulting code will be like this

Dim MyVar

MyVar = "<%txt_body%>"

'resulting code
'this cause syntax error, cannot have unescape quote inside quote
MyVar = "he says,"hello""

'this cause syntax error, cannot unclosed second line
MyVar = "first line
               second line"

What you can do is to use rendertag to escape the text. This method handles, &, ", ', accented character like (á, é, í, ó, ú, ü, ñ, ¿, ¡), and new line carriage return

Dim MyVar

MyVar = "<%!! Escape:HtmlEncode(<%txt_body%>) !!%>"

No comments:

Post a Comment