views:

28

answers:

1

how can I escape " in NVelocity ?

e.g. test.message = "136# 1/4" Test Test Test"

if I do <input type="text" id="Test.Description" value="$test.message"/>

it displays : 136# 1/4

if I do <input type="text" id="Test.Description" value=$test.message/>

it displays : 136

if I do <input type="text" id="Test.Description" value='$test.message'/>

it displays : 136# 1/4" Test Test Test but it escapes '

how can I display 136# 1/4" Test Test Test without escaping anything ?

+1  A: 

nVelocity, at this time, has no built-in facility for HTML-encoding it's variables (there has been some talk about adding it in a future version)

In the meantime, in your controller, you'll just need to do:

test.message = HttpUtility.HtmlEncode(test.message);

or

test.message = test.message.Replace("\"", "&quot;");
James Curran