更新面板不能异步工作 [英] Update panel not working asynchronously
本文介绍了更新面板不能异步工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨。
我有一个母版页面,我在其中放置了一个脚本管理器,如下:
Hi.
I have a Master page where I have placed a Script Manager as under:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
在内容页面中,我有一个带有Datalist的更新面板和按钮如下:
In content page, I have an Update Panel with the Datalist and a Button as follows:
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DataList ID="DataList1" runat="server" onitemdatabound="DataList1_ItemDataBound" RepeatLayout="Flow">
<ItemTemplate>
<div class="post-heading">
<div class="pull-left image">
<img src="abc.jpg" class="img-circle avatar" alt="user profile image">
</div>
<div class="pull-left meta">
<div class="title h5">
<a href="#"><b>Ryan Haywood</b></a>
made a post.
</div>
<h6 class="text-muted time">1 minute ago</h6>
</div>
</div>
<div class="post-description">
<asp:Image ID="Image2" class="img img-responsive" ImageUrl='<%#Eval ("pimg") %>' runat="server" />
<p><asp:Label ID="postlabel" class="postlabel" runat="server" Text='<%#Eval ("ptext") %>'></asp:Label></p>
<div class="stats">
<a href="#" class="btn btn-default stat-item">
<i class="fa fa-thumbs-up icon"></i>2
</a>
<a href="#" class="btn btn-default stat-item">
<i class="fa fa-share icon"></i>12
</a>
</div>
</div>
<div class="post-footer">
<div class="input-group">
<input class="form-control" placeholder="Add a comment" type="text">
<span class="input-group-addon">
<a href="#"><i class="fa fa-edit"></i></a>
</span>
</div>
</div>
</ItemTemplate>
</asp:DataList>
<asp:Button ID="Button2" class="btn-block btn-primary" runat="server" Text="Load More" onclick="Button2_Click" ClientIDMode="Static" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
The problem is that when I click on this Load More button, data is fetched fine but full page postback is happening instead of partial postback.
Why and how it can be resolved?
What I have tried:
I have tried to place the button outside the update panel, still it didnt work
推荐答案
1。首先尝试将ClientIDMode =static
更改为ClientIDMode =AutoID
。
1. First of all try changingClientIDMode="static"
toClientIDMode="AutoID"
.
<asp:button id="Button2" class="btn-block btn-primary" runat="server" text="Load More" onclick="Button2_Click" clientidmode="AutoID"></asp:button>
2.如果上述步骤无效,请尝试设置 UpdateMode =条件
和 ChildrenAsTriggers =true
如下所示 -
2. If the above step doesn't help, try setting UpdateMode="Conditional"
and ChildrenAsTriggers="true"
Something like following-
<asp:updatepanel id="UpdatePanel1" runat="server" childrenastriggers="true" updatemode="Conditional"></asp:updatepanel>
希望,它有帮助:)
Hope, it helps :)
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button2"/>
</Trigger>
<ContentTemplate>
这篇关于更新面板不能异步工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文