如何在不刷新整个页面的情况下回调asp.net按钮?

问题描述

enter image description here

我想在转发器中更改内容而不刷新整个页面。 这样我找到了“ CallBack”,但我不知道如何使用。 按钮是“最佳游戏”,“新游戏”。 当我单击“最佳游戏”时,Repeater的内容更改为最佳游戏,而没有刷新。 当我单击“ Newgames”时,Repeater的内容将在不刷新的情况下更改有关newgames的内容。 请帮助我。

<asp:Button ID="btn_bestgames" runat="server" OnClientClick="onClickBestGames(); return false;"/>

<asp:Button ID="btn_newgames" runat="server" OnClientClick="onClickNewGames(); return false;"/>
function onClickBestGames() {
            document.getElementById("div_wrap_p_bestgames").style.background = "#1B1C1E";
            document.getElementById("div_wrap_p_newgames").style.background = "transparent";
            <% BestGames_Click(); %>
        }

        function onClickNewGames() {

            document.getElementById("div_wrap_p_newgames").style.background = "#1B1C1E";
            document.getElementById("div_wrap_p_bestgames").style.background = "transparent";
            <% NewGames_Click(); %>
        }
public void BestGames_Click()
{
   bestgamesAdapter = dbManager.SetBestGamesAdapter();
   bestgamesAdapter.Fill(bestDT);
   bestgamesRepeater.DataSource = bestDT;
   bestgamesRepeater.DataBind();
   div_wrap_p_bestgames.Style["background"] = "1B1C1E";
   div_wrap_p_newgames.Style["background"] = "transparent";
}

public void NewGames_Click()
{
   newDT = new DataTable();
   newgamesAdapter = dbManager.SetNewGamesAdapter();
   newgamesAdapter.Fill(newDT);
   bestgamesRepeater.DataSource = newDT;
   bestgamesRepeater.DataBind();
   div_wrap_p_bestgames.Style["background"] = "transparent";
   div_wrap_p_newgames.Style["background"] = "1B1C1E";
}

        
public sqlDataAdapter SetBestGamesAdapter()
{
    sqlDataAdapter dataAdapter = new sqlDataAdapter("SELECT * FROM(SELECT ROW_NUMBER() OVER(ORDER BY 
    평점 DESC) AS rownum,*FROM 게임타이틀) AS best WHERE best.rownum BETWEEN 1 AND 8",myConn);
    return dataAdapter;
}


public sqlDataAdapter SetNewGamesAdapter()
{
    sqlDataAdapter dataAdapter = new sqlDataAdapter("SELECT * FROM(SELECT ROW_NUMBER() OVER(ORDER BY 
    출시일 DESC) AS rownum,*FROM 게임타이틀) AS release WHERE release.rownum BETWEEN 1 AND 8",myConn);
    return dataAdapter;
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)