A
Andy Fish
When using databinding, I have gotten into the habit of using single quotes
(apostrophe) round attribute values rather than double quotes because this
allows visual studio to work when there are quotation marks in the
databinding expression. As far as I can tell this seems to be recommended
practice.
However, I just realised that HtmlEncode doesn't encode apostrophes, so if
you do something like this
<a href=... title='<%#Server.HtmlEncode(DataBinder.Eval(Container,
"DataItem.FullName"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
Assuming not, does this mean I have to write my own version of HtmlEncode?
TIA
Andy
(apostrophe) round attribute values rather than double quotes because this
allows visual studio to work when there are quotation marks in the
databinding expression. As far as I can tell this seems to be recommended
practice.
However, I just realised that HtmlEncode doesn't encode apostrophes, so if
you do something like this
<a href=... title='<%#Server.HtmlEncode(DataBinder.Eval(Container,
"DataItem.FullName"))%>' >
you will be screwed if the full name contains an apostrophe.
Is it really unacceptable to use single quotes for HTML attribute values?
Assuming not, does this mean I have to write my own version of HtmlEncode?
TIA
Andy