选中 CheckBox 时在 UpdatePanel 内发生回发
我有一个 ListView
,里面有一个 CheckBox
,其中 AutoPostBack
设置为 true
,我还有一个可折叠面板保存在与此 CheckBox
相邻的同一个 ListView
内。
整个内容都保存在 UpdatePanel
中以进行静默回发。现在我的问题是,即使它保存在 UpdatePanel
中,当我单击 CheckBox
时,整个页面都会刷新。我需要使用静默回发来完成此操作。我怎样才能实现这个目标?
<asp:ListView ID="ListViewGroups" runat="server"
onitemdatabound="ListView1_ItemDataBound">
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Panel ID="PanelContainer" runat="server" Width="400px">
<asp:Panel ID="PanelHeaderList" runat="server" Width="20px">
<div style="float:left;" >
<asp:ImageButton ID="Image1" runat="server"
ImageUrl="~/expand_blue.jpg"
AlternateText="(Show Details...)"/>
</div>
</asp:Panel>
<div style="float:left;" >
<asp:CheckBox ID="CheckBox1" runat="server"
AutoPostBack="true" />
<asp:Label ID="Grp_NameLabel" runat="server"
Text='<%# Eval("Grp_Name") %>' />
<asp:HiddenField ID="hfGrpID" runat="server"
Value='<%#Eval("Grp_ID") %>' />
</div>
<br />
<p>
<asp:Panel ID="PanelGroupsItem" runat="server"
Width="100px" >
<asp:Panel ID="MyGroups" runat="server"
ScrollBars="Vertical"
Height="200px"
Width="300px"
Visible='<%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %>'>
//Another Normal gridView here just showing some data
</asp:Panel>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
runat="server"
Collapsed="true"
TargetControlID="PanelGroupsItem"
CollapseControlID="PanelHeaderList"
ExpandControlID="PanelHeaderList"
ImageControlID="Image1"
ExpandedImage="~/collapse_blue.jpg"
CollapsedImage="~/expand_blue.jpg"
SuppressPostBack="true"
>
</asp:CollapsiblePanelExtender>
</asp:Panel>
</p>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server"
border="0" style="">
<tr runat="server" style="">
<th runat="server">
Groups</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
请帮我解决这个问题
I have a ListView
and inside it I'm having a CheckBox
for which AutoPostBack
is set to true
, I also have a Collapsible panel kept inside the same ListView
adjacent to this CheckBox
.
The entire thing is kept inside an UpdatePanel
for Silent Post back. Now my problem is even though it is kept inside a UpdatePanel
when I click on the CheckBox
the Entire page is getting Refreshed. I need to do it using a Silent PostBack. How can i Achieve this??
<asp:ListView ID="ListViewGroups" runat="server"
onitemdatabound="ListView1_ItemDataBound">
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:Panel ID="PanelContainer" runat="server" Width="400px">
<asp:Panel ID="PanelHeaderList" runat="server" Width="20px">
<div style="float:left;" >
<asp:ImageButton ID="Image1" runat="server"
ImageUrl="~/expand_blue.jpg"
AlternateText="(Show Details...)"/>
</div>
</asp:Panel>
<div style="float:left;" >
<asp:CheckBox ID="CheckBox1" runat="server"
AutoPostBack="true" />
<asp:Label ID="Grp_NameLabel" runat="server"
Text='<%# Eval("Grp_Name") %>' />
<asp:HiddenField ID="hfGrpID" runat="server"
Value='<%#Eval("Grp_ID") %>' />
</div>
<br />
<p>
<asp:Panel ID="PanelGroupsItem" runat="server"
Width="100px" >
<asp:Panel ID="MyGroups" runat="server"
ScrollBars="Vertical"
Height="200px"
Width="300px"
Visible='<%# GetFlag(Convert.ToInt32(Eval("Grp_ID"))) %>'>
//Another Normal gridView here just showing some data
</asp:Panel>
</asp:Panel>
<asp:CollapsiblePanelExtender ID="CollapsiblePanelExtender1"
runat="server"
Collapsed="true"
TargetControlID="PanelGroupsItem"
CollapseControlID="PanelHeaderList"
ExpandControlID="PanelHeaderList"
ImageControlID="Image1"
ExpandedImage="~/collapse_blue.jpg"
CollapsedImage="~/expand_blue.jpg"
SuppressPostBack="true"
>
</asp:CollapsiblePanelExtender>
</asp:Panel>
</p>
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server"
border="0" style="">
<tr runat="server" style="">
<th runat="server">
Groups</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
Please help me on this
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在这里找到了类似问题的解决方案: 当选中某个项目时,UpdatePanel 内的复选框列表会触发完整回发。
您需要将复选框的ClientID模式设置为AutoID。
I found the solution for a similar issue here: Checkboxlist inside UpdatePanel triggers full postback when an item is checked.
You need to set the ClientID mode of the checkBox to AutoID.