views:

127

answers:

3

Sounds dummy but I can't set to a server-side control's property a value contains quote marks ":

<asp:CompareValidator ErrorMessage="Currency-from can't be equal to currency-to" runat="server"  />

I need to quote "from" and "to".

I tried escaping \"from\" and double quote marks ""from"" - both doesn't work. How to do that?

+2  A: 

You could just use single quotes.

Or replace the double quotes with "&quot ;" (without the space between the t and semi-colon)

David Neale
Single quote using like `ErrorMessage="Currency "from" can't be.."` doesn't work
abatishchev
I mean't like `ErrorMessage="Currency 'from' can't be.."` - but I would just use `"` as everyone has suggested.
David Neale
+2  A: 

Hi, try this

<asp:CompareValidator ErrorMessage="Curreny&quot;from&quot; can't be equal 
to currency &quot;to&quot;" runat="server">

Single quotes won't work because you also have a single quote on the text

Claudio Redi
+2  A: 

You can do it using &quot; for quotes, this is how you escape them in HTML, like this:

<asp:CompareValidator runat="server" ErrorMessage="Currency &quot;from&quot; can't be equal to currency &quot;to&quot;" />

(Also, fix the first spelling or Currency!)

Nick Craver