如果在另一個UpdatePanel
內部有UpdatePanel
,並且在內部的UpdatePanel中有一個按鈕,我想單擊此按鈕時只刷新內部的UpdatePanel
。怎麼樣 ?只刷新另一個UpdatePanel中的UpdatePanel
4
A
回答
3
在innerupdate面板中,將updatemode設置爲conditional,並將outerupdatepanel childrenastriggers屬性設置爲false。在內部更新面板中添加一個postbacktrigger並將其設置爲將導致回發的按鈕。這樣
<asp:UpdatePanel ID="parentup" runat="server" ChildrenAsTriggers="false">
<ContentTemplate>
<asp:UpdatePanel ID="chidlup" UpdateMode="Conditional" runat="server">
<ContentTemplate>
<asp:Button ID="btn" runat="server" />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btn" />
</Triggers>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>
4
@Waqar揚尤亞事情是正確的。
但是,您不必將ChildrenAsTriggers設置爲false,有時將它保留爲true會更方便。
在您的兩個更新面板中設置屬性UpdateMode =「條件」(將ChildrenAsTriggers的默認值設置爲true)。然後之間的:到觸發添加到您的按鈕,揚尤亞稱:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn" />
</Triggers>
當將UpdateMode不是條件各的UpdatePanel將更新它。
0
此代碼可以幫助你:這裏是Source
<asp:ScriptManager ID="script1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:Label ID="lblTime" runat="server" ForeColor="Red"></asp:Label>
<asp:Button ID="buttonOuter" runat="server" OnClick="buttonOuter_Click" Text="What is the time?" />
<asp:UpdatePanel ID="up2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTime2" runat="server" ForeColor="Blue"></asp:Label>
<asp:Button ID="buttonInner" runat="server" OnClick="buttonInner_Click" Text="What is the time?" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="buttonOuter" EventName="Click"/>
</Triggers>
</asp:UpdatePanel>
這裏是code behinde
:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void buttonInner_Click(object sender, EventArgs e)
{
up2.Update();
lblTime2.Text = DateTime.Now.Second.ToString();
}
protected void buttonOuter_Click(object sender, EventArgs e)
{
lblTime.Text = DateTime.Now.Second.ToString();
}
0
如果UP1是外部的UpdatePanel,和UP2是內在的,並且要防止外部用內部按鈕進行更新(對於exp:Btn):
UP1.UpdateMode="Conditional"
UP1.ChildrenAsTriggers= "False"
您也不應工作添加BTN作爲UP1觸發器(如下面的代碼)
<asp:UpdatePanel ID="UP1" runat="server" ....>
<ContentTemplate>
....
</ContentTemplate>
<Triggers>
<asp:Trigger ControlID="btn" EventName="Click"/>
</Triggers>
</asp:UpdatePanel>
相關問題
- 1. 刷新UpdatePanel
- 2. Asp.net updatePanel刷新
- 3. 的UpdatePanel刷新一次
- 4. [asp.net]的UpdatePanel刷新一次
- 5. 的UpdatePanel刷新IE7
- 6. 的GridView中的UpdatePanel刷新
- 7. ASP.NET刷新UpdatePanel OnClientClick
- 8. 使用UpdatePanel控件只刷新內容
- 9. 從第二UpdatePanel更新一個UpdatePanel
- 10. 嵌套的UpdatePanel刷新父
- 11. UpdatePanel刷新時運行javascript
- 12. 的UpdatePanel有時刷新整個頁面
- 13. 「預覽區」中的UpdatePanel不刷新
- 14. UpdatePanel中的標籤文本不刷新
- 15. 從不同的UpdatePanel回發後顯示並刷新UpdatePanel?
- 16. updatepanel刷新整個頁面在asp.net
- 17. gridview不刷新後updatepanel中刪除
- 18. 在UpdatePanel中UpdateMethod之後刷新GridView
- 19. 在一個UpdatePanel
- 20. 在一個UpdatePanel
- 21. 固定後刷新的UpdatePanel間隔
- 22. UpdatePanel中從更新
- 23. UpdatePanel只在一個gridview列上?
- 24. 佔位一個UpdatePanel
- 25. 自動刷新UpdatePanel每隔5秒
- 26. 使用UpdatePanel刷新ListView在asp:webform
- 27. ViewState在UpdatePanel刷新時丟失了?
- 28. UpdatePanel在刷新期間沒有修復
- 29. updatepanel和updateprogress刷新PDF響應
- 30. Asp.net updatepanel Listbox不刷新佈局
THX,我 – aref 2018-02-15 08:26:48