how to escape double quotes in text property aspx file

I recently had a facepalm moment when I experienced an issue with a text property of a user control in my aspx file that had a custom property that included double quotes. Double quotes confused the compiler and made it believe that the ID property of my user control used in cs file didn’t exist.

After wasting some time on the wrong problem, it came down to escaping the double quotes. Aspx files are like XML and need to be treated like one in the text property of attributes used in the form controls.

To escape a double quote you need to use quot; e.g.

HeaderText="This is a "double quote""

will show up as below:

This is a “double quote”

Similarly for other such characters, use below ones:
 ampersand &   =>   &
 single quotes '   =>   '
 less than <   =>   &lt;
 greater than >   =>   &gt;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.