views:

43

answers:

3

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.

A: 

Out of curiosity, what renders if you change

   objListBox.Attributes.Add("onchange", "Control_doPostBack('" + objListBox.ClientID + "','ListBox_OnClick'); return false;");

to

   objListBox.Attributes.Add("onchange", "Control_doPostBack(\'" + objListBox.ClientID + "\',\'ListBox_OnClick\'); return false;");

?

Daniel Dyson
it renders as \'
Juergen Hoffmann
A: 

The browser is in error. name="a'b'c" and name="a&#39;b&#39;c" are two completely equivalent ways of specifying an attribute whose value is a'b'c.

Kevin Reid
yes, you are right, it shouldn't make a difference. But IE8 makes a difference. IE8 throws a JS Error.
Juergen Hoffmann
A: 

I'm having the same problem did you find an answer?

Gavin Smith