asp.net 可折叠面板展开或折叠时更改按钮文本
Changing button text when asp.net collapsible panel expands or collapses
我正在使用 show/hide 一个 asp 可折叠面板的按钮。如何在面板折叠时将按钮的文本更改为 show
,在展开时将按钮的文本更改为 hide
?
我尝试使用 TextLabelID="btnShowHideRequestComment" CollapsedText="Show" ExpandedText="Hide"
但没有成功。
<asp:Panel ID="pnlRequestCommentHistory" runat="server">
<asp:GridView ID="gvwRequestCommentHistory" runat="server"
AutoGenerateColumns="False" CssClass="GridStyle"
DataSourceID="odsRequestCommentHistory">
<Columns>
<asp:BoundField DataField="Name" HeaderText="User" SortExpression="Name" />
<asp:BoundField DataField="CommentDate" HeaderText="Date"
SortExpression="CommentDate" />
<asp:BoundField DataField="Comment" HeaderText="Comment"
SortExpression="Comment" />
</Columns>
<AlternatingRowStyle CssClass="GridAlternateRowStyle" />
<RowStyle CssClass="GridRowStyle" />
</asp:GridView>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpeRequestCommentHistory" runat="server"
TargetControlID="pnlRequestCommentHistory" CollapseControlID="btnShowHideRequestComment" ExpandControlID="btnShowHideRequestComment"
Collapsed="true" CollapsedSize="0" TextLabelID="btnShowHideRequestComment" CollapsedText="Show" ExpandedText="Hide">
</asp:CollapsiblePanelExtender>
我从 here 找到以下解决方案:
protected void btnShowHideRequestComment_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
if (btnShowHideRequestComment.Text == "Show")
btnShowHideRequestComment.Text = "Hide";
else
btnShowHideRequestComment.Text = "Show";
}
}
我正在使用 show/hide 一个 asp 可折叠面板的按钮。如何在面板折叠时将按钮的文本更改为 show
,在展开时将按钮的文本更改为 hide
?
我尝试使用 TextLabelID="btnShowHideRequestComment" CollapsedText="Show" ExpandedText="Hide"
但没有成功。
<asp:Panel ID="pnlRequestCommentHistory" runat="server">
<asp:GridView ID="gvwRequestCommentHistory" runat="server"
AutoGenerateColumns="False" CssClass="GridStyle"
DataSourceID="odsRequestCommentHistory">
<Columns>
<asp:BoundField DataField="Name" HeaderText="User" SortExpression="Name" />
<asp:BoundField DataField="CommentDate" HeaderText="Date"
SortExpression="CommentDate" />
<asp:BoundField DataField="Comment" HeaderText="Comment"
SortExpression="Comment" />
</Columns>
<AlternatingRowStyle CssClass="GridAlternateRowStyle" />
<RowStyle CssClass="GridRowStyle" />
</asp:GridView>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="cpeRequestCommentHistory" runat="server"
TargetControlID="pnlRequestCommentHistory" CollapseControlID="btnShowHideRequestComment" ExpandControlID="btnShowHideRequestComment"
Collapsed="true" CollapsedSize="0" TextLabelID="btnShowHideRequestComment" CollapsedText="Show" ExpandedText="Hide">
</asp:CollapsiblePanelExtender>
我从 here 找到以下解决方案:
protected void btnShowHideRequestComment_Click(object sender, EventArgs e)
{
if (IsPostBack)
{
if (btnShowHideRequestComment.Text == "Show")
btnShowHideRequestComment.Text = "Hide";
else
btnShowHideRequestComment.Text = "Show";
}
}