【问题标题】:ASP.NET: CollapsiblePanelExtender doesn't work with UserControlASP.NET:CollapsiblePanelExtender 不适用于 UserControl
【发布时间】:2010-03-02 10:52:21
【问题描述】:

我正在尝试使用名为 CheckBoxControl 的用户控件作为 CollapsiblePanelExtender 的 ExpandControlID/CollapseControlID 属性的值。当我使用普通的 CheckBox 时,它工作正常。

<uc:CheckBoxControl ID="ucHaftpflicht" runat="server" OnCheckedChanged="UpdateStatus" ControlLabel="Haftpflicht" />           
<asp:Panel ID="HaftpflichtPanel" runat="server">
       ...
</asp:Panel>
<asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender" runat="server" CollapseControlID="ucHaftpflicht.CheckBox" ExpandControlID="ucHaftpflicht.CheckBox"  TargetControlID="HaftpflichtPanel" />

当我运行该网站时,我网站上的大多数 ajax 控件都会消失,并且我在 firefox 脚本错误控制台中收到以下错误:

  • Fehler:Sys.InvalidOperationException:处理程序未通过 Sys.UI.DomEvent.addHandler 方法添加。

  • Fehler:Sys.ArgumentException:未能找到元素“ucHaftpflicht.CheckBox” 参数名称:CollapseControlID

【问题讨论】:

    标签: asp.net ajax user-controls


    【解决方案1】:

    通过 UserControl 中的 getter 公开复选框,并在页面的代码隐藏中将 CollapsiblePanelExtender 折叠/展开控件 ID 分配给 ucHaftpflicht.MyCheckBox.ClientID

    【讨论】:

    • 我希望有一个声明性的解决方案而不是一个程序性的解决方案:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多