VS2010 renders controls JS awkwardly

Posted by Juergen Hoffmann on Stack Overflow See other posts from Stack Overflow or by Juergen Hoffmann
Published on 2010-05-05T10:34:28Z Indexed on 2010/05/05 10:38 UTC
Read the original article Hit count: 268

Filed under:
|
|

I have created a Website Project in VS2010. My Controls are not rendered correctly. The JS that is produced is not correctly formatted. Here is an example:

    protected void Page_PreRender(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            objListBox.Attributes.Add("onchange", "Control_doPostBack('" + objListBox.ClientID + "','ListBox_OnClick'); return false;");
            objListBox.Attributes.Add("onblur", "Control_doPostBack('" + trListbox.ClientID + "','ListBox_OnBlur'); return false;");
            img.Attributes.Add("onclick", "Control_doPostBack('" + trListbox.ClientID + "','IMG_OnClick'); return false;");
        }
    }

and the responding control is rendered as:

<select size="4" name="ctl00$PlaceHolder_Content$drop$objListBox" onchange="Control_doPostBack(&#39;PlaceHolder_Content_drop_objListBox&#39;,&#39;ListBox_OnClick&#39;); return false;setTimeout(&#39;__doPostBack(\&#39;ctl00$PlaceHolder_Content$drop$objListBox\&#39;,\&#39;\&#39;)&#39;, 0)" id="PlaceHolder_Content_drop_objListBox" onblur="Control_doPostBack(&#39;PlaceHolder_Content_drop_trListbox&#39;,&#39;ListBox_OnBlur&#39;); return false;" style="position:absolute;"> 

 </select>

As you can see, the ' are rendered to &#39 which screwes up the Browser.

Is there a tweak to msbuild or inside the project properties?

Any help is highly appreciated.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about VS2010