Control Attributes render Encoded on dot net 4 - how to disable the encoding ?

Posted by Aristos on Stack Overflow See other posts from Stack Overflow or by Aristos
Published on 2010-05-26T11:22:36Z Indexed on 2010/06/02 14:34 UTC
Read the original article Hit count: 290

I have an issue in asp.net 4.

When I add an attribute on controls, then the render it encoded.

For example, when I type this code

txtQuestion.Attributes["onfocus"] = 
    "if(this.value == this.title)
{
   this.value = '';
   this.style.backgroundColor='#FEFDE0';
   this.style.color='#000000';
}";

I get render

onfocus="if(this.value == this.title){this.value = 
'';this.style.backgroundColor='#FEFDE0';
this.style.color='#000000';}"

And every ' hash been change to & #39;

Is there a way to disable this new future only on some controls ? or an easy way to make a custom render ?

My Fail tries

I have all ready try some thinks but I fail. For example this fails.

txtQuestion.RenderingCompatibility = new Version("3.5");

I also locate the point that this attributes renders and is on

public virtual void RenderBeginTag(HtmlTextWriterTag tagKey) function,

there every attribute have a flag if he wish to be encoded, but I do not know how can anyone set it or not.

Anyway, thank you in advanced.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about controls