Kees C. Bakker
Kees C. Bakker

Reputation: 33431

How to do do HtmlTextWriter.WriteAttribute with a single quote?

I'm writing a control to support HTML5 video. The type attribute has to specify the codec as well. Some examples show: type='video/mp4; codecs="avc1.42E01E, mp4a.40.2"'. When I'm writing the codec with the HtmlWriter, it flushes type="video/mp4; codecs="avc1.42E01E, mp4a.40.2"". So far so good, but my iPhone and iPad browsers refuse to work with the ".

I'm using a WriteAttribute. How can I accomplish the writing of single quoted attributes?

Upvotes: 2

Views: 626

Answers (1)

Efran Cobisi
Efran Cobisi

Reputation: 6484

I suggest you to do just the opposite: output the attribute in the HtmlWriter standard way (double quotes) and just embed your codecs option within a couple of single quotes. That should make the trick here.

Upvotes: 2

Related Questions