0
我想停止頁面刷新Ajax調用。我創建了多個視圖,當用戶點擊樹視圖中的鏈接按鈕時,這些視圖會打開。如何在ajax調用中停止asp.net中的頁面刷新?
在每個按鈕上單擊視圖在頁面刷新後打開。當用戶單擊按鈕並停止頁面刷新和顯示數據時,我想要加載圖像圖標。
有人可以幫我解決這個問題嗎?
樹視圖:
<ul>
<li>
<asp:LinkButton runat="server" OnClientClick="DisplayLoadingDiv()" ID="Button1" Text="Add Institute" OnClick="Button1_Click" />
</li>
服務器端代碼:
protected void Button1_Click(object sender, EventArgs e)
{
MultiView1.Visible = true;
MultiView1.SetActiveView(View1);
}
你的Ajax調用將工作顯示codezz – BenG
阿賈克斯不會對自己的頁面刷新。如果它是由按鈕按下或鏈接點擊觸發的,則需要使用'event.preventDefault();'來停止通常的頁面改變行爲('event'將是事件監聽器接收到的第一個參數)。 – Whothehellisthat
@Whathehellisthat謝謝你的答覆。保護void Button1_Click(object sender,EventArgs e) { MultiView1.Visible = true; MultiView1.SetActiveView(View1); } 是我的代碼。我不能把e.preventDefault();你可以幫助我在哪裏以及如何使用它。我是新手。 –