apparently attributes on web controls are automatically partially encoded

for example, if you do the following

System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
img.Attributes.Add("whatever","<");

you get this in html

<img whatever="&lt;" />

(the < is encoded)
but,

img.Attributes.Add("whatever",">");

results in

<img whatever=">"/>

(the > is not encoded)

i dont know why. it would be nice if the developer could be trusted to do his own half assed encoding if the need came up, instead of fighting to undo it... anyway, how do i undo it? i need to make it not screw up my code so i can pass html to a js function

dont worry about it. it turns out all the "&lt;"s werent an obstacle. just a distracting bunch of encoded characters. i figured out they can be decoded back to normal with some ascii anyway - .replace('<',String.fromCharCode('60')) - right before i figured out they werent causing a problem...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.