如何在ASP.NET中为CollapsiblePanelExtender设置两个按钮?
说,我有一个带有图像的面板和一些用文字分隔的文本。我希望我的图像和文本成为扩展/折叠我的面板的触发器。
答案 0 :(得分:0)
将ImageButtion添加为ExpandControl并使用textbox keyup事件在客户端扩展扩展程序:
function expand() {
var extender = $find("CollapsibleExtender1");
if (extender.get_Collapsed()) {
$find("CollapsibleExtender1").expandPanel();
}
}
<asp:Panel runat="server" ID="CollapsiblePanel">
Cursus et amet cras egestas, turpis cras tempor diam scelerisque habitasse in, platea
augue turpis. Odio? Risus, ultricies! Dapibus risus sit. Placerat et in parturient
tristique, natoque porttitor, platea aenean, a, platea etiam urna, a cum nunc! Parturient
platea, sit mauris proin, magna lacus, eros, in sed nascetur tempor adipiscing.
</asp:Panel>
<asp:ImageButton runat="server" ID="MyImageButton" ImageUrl="~/Images/infoindicator.gif" />
<asp:Button runat="server" ID="MyButton" Text="Click Me" OnClientClick="expand(); return false;" />
<ajax:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" BehaviorID="CollapsibleExtender1"
ExpandControlID="MyImageButton" Collapsed="true" TargetControlID="CollapsiblePanel"
CollapsedText="Collapsed" ExpandedText="Expanded" SuppressPostBack="true" />