我有一个带有两个更新面板的网络表单:
<asp:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Release">
</asp:ScriptManager>
<p>
<asp:UpdatePanel ID="upl1" runat="server">
<ContentTemplate>
<asp:Button runat="server" ID="btn1" Text="Button1" />
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel ID="upl2" runat="server">
<ContentTemplate>
<asp:Button runat="server" id="btn2" Text="Button2" />
</ContentTemplate>
</asp:UpdatePanel>
</p>
如果我点击btn1
,则会触发upl2
的加载事件,以及upl1
。
我希望仅加载 upl1
,因为这是包含该按钮的更新面板。
为什么这种情况没有发生,我怎样才能让它发生?
最佳答案
我在使用更新面板时经常使用的一个做法是设置属性:
ChildrenAsTriggers="false" UpdateMode="Conditional"
And refresh the Update Panel only when I want:
protected void btn1_Click(object sender, EventArgs e)
{
// some logic
// ....
upl1.Update();
}
尝试应用这些属性,看看是否能解决您的问题。
关于asp.net - 当我单击其中一个更新面板中的按钮时,如何防止所有更新面板重新加载?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15024123/