使用Ajax Extender时出错

时间:2013-08-30 09:06:20

标签: asp.net ajax

我在按钮上使用Ajax下拉列表扩展器。但是获得运行时错误

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).

当编译器尝试编译extenderbase类时,它会发生。类中的错误代码是

  link.Attributes.Add("rel", "stylesheet");
                header.Controls.Add(link);

 //here i am getting the error            -->   // ASP.NET AJAX doesn't currently send a new head element down during an async postback,
                // so we do the same thing on the client by registering the appropriate script for after
                // the update.

我应该尝试删除Error.also我更改了ajax工具包版本但是没有用,我改变了&lt;%=%&gt;到&lt; @#%&GT;在母版页,但als不起作用。我正在使用Visual Web developer 2010。

1 个答案:

答案 0 :(得分:1)

尝试使用格式&lt;%#.....%&gt;在你的标记中,然后在你的Page_Load方法中,在代码隐藏中放入这一行

Page.Header.DataBind();