[英]Difference between AsyncPostBackTrigger and PostBackTrigger on UpdatePanel?
I have a GridView
(ucLAD) in my UpdatePanel
(upnlListing). 我的UpdatePanel
(upnlListing)中有一个GridView
(ucLAD)。 Inside my ucLAD
I have a checkbox and an action for rowClicked
: 在我的ucLAD
里面,我有一个复选框和rowClicked
的动作:
<asp:UpdatePanel ID="upnlListing" runat="server" >
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ucLAD"/>
<%-- <asp:PostBackTrigger ControlID="ucLAD"/> --%>
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlRequest" runat="server" style="margin-top:15px; height: auto;">
<ucgv:BaseGrid runat="server" ID="ucLAD"/>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
When I use the PostBackTrigger
the action performed would be the rowClicked
same thing happen when I check the checkbox but when I use the AsyncPostBackTrigger
, I can check the checkboxes but when I click the row, the action for rowClicked
don't trigger. 当我使用PostBackTrigger
,执行的操作将是rowClicked
当我检查复选框时发生同样的事情但是当我使用AsyncPostBackTrigger
,我可以检查复选框但是当我单击该行时, rowClicked
操作不会触发。 How can I fix this? 我怎样才能解决这个问题?
As describe in on of the SO question 正如SO问题所描述的那样
What is the difference between AsyncPostBackTrigger & PostBackTrigger? AsyncPostBackTrigger和PostBackTrigger有什么区别?
Controls inside an UpdatePanel by default cause a partial page update, controls outside cause a postback, using these triggers it is possible to change this behaviour as required. 默认情况下,UpdatePanel内部的控件会导致部分页面更新,外部控件会导致回发,使用这些触发器可以根据需要更改此行为。
From http://seminaarit.codezone.fi/video/devdays-2007/track1/2/2-ASP-dotNET_AJAX_Extensions.ppt 来自http://seminaarit.codezone.fi/video/devdays-2007/track1/2/2-ASP-dotNET_AJAX_Extensions.ppt
Converts postbacks into async callbacks Typically used to trigger updates when controls outside an UpdatePanel post back If ChildrenAsTriggers="false", can be used to specify which controls inside UpdatePanel should call back rather than post back 将回发转换为异步回调通常用于在UpdatePanel回调之外的控件后触发更新如果ChildrenAsTriggers =“false”,可用于指定UpdatePanel内的哪些控件应该回调而不是回发
Lets controls inside UpdatePanel post back Typically used to allow certain controls to post back when ChildrenAsTriggers="true 让UpdatePanel内部的控件回发通常用于允许某些控件在ChildrenAsTriggers =“true”时回发
Theoretical explain for AsyncPostBackTrigger and PostBackTrigger above is absolutely Correct. 上面的AsyncPostBackTrigger和PostBackTrigger的理论解释绝对是正确的。 Here I gave You example for those two: 在这里,我给了你这两个例子:
<td style="padding-left: 8px;">
<asp:UpdatePanel runat="server" ChildrenAsTriggers="false" UpdateMode="conditional">
<ContentTemplate>
<asp:RadioButton ID="RBtn_InventoryPriceWithPurchase" Text="Inventory Price With Purchase" GroupName="ReportAnalysis" runat="server" AutoPostBack="True" OnCheckedChanged="RBtn_InventoryPriceWithPurchase_CheckedChanged"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="RBtn_InventoryPriceWithPurchase"EventName="CheckedChanged"/>
</Triggers>
</asp:UpdatePanel>
</td>
<td style="padding-left: 8px;">
<asp:UpdatePanel runat="server" ChildrenAsTriggers="True" UpdateMode="Always">
<ContentTemplate>
<asp:RadioButton ID="RBtn_MerchandisingReport" Text="Merchandising Report" GroupName="ReportAnalysis" runat="server" AutoPostBack="True" OnCheckedChanged="RBtn_MerchandisingReport_CheckedChanged" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="RBtn_MerchandisingReport"/>
/Triggers>
</asp:UpdatePanel>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.