【发布时间】:2010-12-10 02:30:44
【问题描述】:
我有一个棘手的场景,我想仅在某些条件下添加 ScriptManager 脚本引用,如下所示
<asp:ScriptManagerProxy ID="scriptManagerProxy1" runat="server">
<CompositeScript>
<Scripts>
<asp:ScriptReference path=/...." />
</Scripts>
</CompositeScript>
<asp:ScriptManagerProxy>
我想让这个脚本只在特定条件下引用,所以我做了如下
<% if(xyzclass.property)
{ %>
above code
<% } %>
一旦我这样做了,我就会得到错误
The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).
我用谷歌搜索并尝试将“#”添加为
Expected class, delegate, enum, interface, or struct
我也尝试过这里提到的工作 http://leedumond.com/blog/the-controls-collection-cannot-be-modified-because-the-control-contains-code-blocks/
到目前为止没有运气。如果我采用上面链接中提到的方法,它会说类似
The base class includes the field '', but its type (System.Web.UI.ScriptManagerProxy) is not compatible with the type of control (System.Web.UI.ScriptManager).
伙计们,我需要的只是通过 ScriptManager 动态添加脚本。有什么方法在实践中也很好。
提前致谢,
尼米什
【问题讨论】:
标签: c# asp.net asp.net-ajax