webforms all children 执行异步回发,即使 updatemode 设置为条件
webforms all children performing async postback even when updatemode set to conditional
我有一个更新面板,其中 UpdateMode 设置为条件,childrenastriggers 设置为 false,但面板中的所有控件都在执行异步 postbacks...
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress ID="pnlUpdateProgress" DisplayAfter="1" runat="server">
<ProgressTemplate>
Update in progress...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" ID="pnlUpdate" UpdateMode="Conditional" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnDoNothing" EventName="Click" />
</Triggers>
<ContentTemplate>
<div runat="server" clientidmode="Static" id="divList">
<asp:Button runat="server" ID="btnDoNothing" Text="Do nothing" OnClick="Unnamed_Click" />
<asp:Button runat="server" ID="btnSync" Text="Sync" OnClick="btnSync_Click" />
<br />
<div class="items_bought_table">
<table style="width: 100%; padding-bottom:24px;">
<thead>
<tr>
<th style="text-align: left;">Description</th>
<th></th>
</tr>
</thead>
<tbody>
<asp:Literal runat="server" ID="litList" />
</tbody>
</table>
</div>
<br />
<asp:Literal runat="server" ID="litDebugText" />
</div>
<div runat="server" clientidmode="Static" id="divEdit">
<asp:HiddenField runat="server" ID="txtEditID" />
<asp:Literal ID="litEditList" runat="server">
</asp:Literal>
<ul>
<li class="full_width pt_10">
Your Product: <em><asp:Literal runat="server" ID="litEditProductName" /></em>
</li>
</ul>
</div>
</ContentTemplate>
</asp:UpdatePanel>
这里 btnSync 和 btnDoNoting 都在执行异步 postbacks,我希望只有 btnDoNothing 到 postback async,btnSync 应该执行完整的 postback
AsyncPostBackTrigger 仅设置面板外的控件。
Controls on the page outside of an update panel can refresh an UpdatePanel control by defining them as triggers. Triggers are defined by using the AsyncPostBackTrigger element.
控制回发总是回发。我 认为 ChildrenAsTriggers="false"
不会停止回发 - 它只会阻止内容更新。
正如@wazz 在他们的回答中所述,这是更新面板中的正常行为。要制作后卫,您需要制作一个“PostBackTrigger”,如 this 问题的答案中所述。
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
...
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="myFullPostBackControlID" />
</Triggers>
</asp:UpdatePanel>
我有一个更新面板,其中 UpdateMode 设置为条件,childrenastriggers 设置为 false,但面板中的所有控件都在执行异步 postbacks...
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdateProgress ID="pnlUpdateProgress" DisplayAfter="1" runat="server">
<ProgressTemplate>
Update in progress...
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel runat="server" ID="pnlUpdate" UpdateMode="Conditional" ChildrenAsTriggers="false">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnDoNothing" EventName="Click" />
</Triggers>
<ContentTemplate>
<div runat="server" clientidmode="Static" id="divList">
<asp:Button runat="server" ID="btnDoNothing" Text="Do nothing" OnClick="Unnamed_Click" />
<asp:Button runat="server" ID="btnSync" Text="Sync" OnClick="btnSync_Click" />
<br />
<div class="items_bought_table">
<table style="width: 100%; padding-bottom:24px;">
<thead>
<tr>
<th style="text-align: left;">Description</th>
<th></th>
</tr>
</thead>
<tbody>
<asp:Literal runat="server" ID="litList" />
</tbody>
</table>
</div>
<br />
<asp:Literal runat="server" ID="litDebugText" />
</div>
<div runat="server" clientidmode="Static" id="divEdit">
<asp:HiddenField runat="server" ID="txtEditID" />
<asp:Literal ID="litEditList" runat="server">
</asp:Literal>
<ul>
<li class="full_width pt_10">
Your Product: <em><asp:Literal runat="server" ID="litEditProductName" /></em>
</li>
</ul>
</div>
</ContentTemplate>
</asp:UpdatePanel>
这里 btnSync 和 btnDoNoting 都在执行异步 postbacks,我希望只有 btnDoNothing 到 postback async,btnSync 应该执行完整的 postback
AsyncPostBackTrigger 仅设置面板外的控件。
Controls on the page outside of an update panel can refresh an UpdatePanel control by defining them as triggers. Triggers are defined by using the AsyncPostBackTrigger element.
控制回发总是回发。我 认为 ChildrenAsTriggers="false"
不会停止回发 - 它只会阻止内容更新。
正如@wazz 在他们的回答中所述,这是更新面板中的正常行为。要制作后卫,您需要制作一个“PostBackTrigger”,如 this 问题的答案中所述。
<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
<ContentTemplate>
...
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="myFullPostBackControlID" />
</Triggers>
</asp:UpdatePanel>