开发者

VS2010 renders controls JS awkwardly

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;L开发者_开发问答istBox_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.


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;");

?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜