第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

自動刷新頁面,數(shù)據(jù)不更新

自動刷新頁面,數(shù)據(jù)不更新

C#
明月笑刀無情 2021-08-07 16:54:56
伙計們,我正在使用 javascript 每 5 秒自動更新一次頁面......但我注意到刷新正在工作,但它沒有更新我的服務(wù)器端數(shù)據(jù)......所以數(shù)據(jù)網(wǎng)格應(yīng)該更新,但事實并非如此。 .. 但如果我按 f5 則數(shù)據(jù)更新...這是我在標記中的 javascript。<script>    //refresh the page (without losing state)    window.setTimeout('document.forms[0].submit()', 5000); </script>(在頭上)page load has all my data i need...   protected void Page_Load(object sender, EventArgs e)        {            if (!IsPostBack)            {                if (DDLProduct.Items.Count == 0)                {                    BindDropDownList();                }                BizManager mgr = new BizManager();                mgr.CalcShiftPeriod();                //stores the bizmanager shiftstart to a backing field                _shiftStart = mgr.Shiftstart;                 _shiftEnd = mgr.Shiftend;#if DEBUG                //tests these values if program is in debug version.                _shiftStart = new DateTime(2013, 08, 27, 6, 00, 00);                 //dismisses if in release version                _shiftEnd = new DateTime(2013, 08, 27, 13, 59, 59); #endif                //passing in the params to the refreshdata method.                RefreshData(Product,  _shiftStart, _shiftEnd);            }        }所以本質(zhì)上頁面正在刷新,但數(shù)據(jù)不是,除非我執(zhí)行 f5 刷新。
查看完整描述

2 回答

?
慕田峪4524236

TA貢獻1875條經(jīng)驗 獲得超5個贊

您實際上并不是刷新頁面,而是提交表單,從而創(chuàng)建回發(fā)。在您的 Page_Load 中,如果數(shù)據(jù)是回發(fā),則不會刷新數(shù)據(jù)。


嘗試將 javascript 更改為:


<script>

   window.setTimeout(function() {

         location.reload();

   }, 5000);

</script>


查看完整回答
反對 回復 2021-08-07
?
紅糖糍粑

TA貢獻1815條經(jīng)驗 獲得超6個贊

我不知道你為什么每 5 秒重新加載一次頁面


Esko 的回答對您有用,但是


你也可以通過Meta Refresh像這樣的使用來刷新


<head>

  <meta http-equiv="refresh" content="10">

</head>

我建議你這樣做:


<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>      

<asp:UpdatePanel runat="server" UpdateMode="Conditional">

    <ContentTemplate>

        <!-- your GridView in UpdatePanel -->

    </ContentTemplate>

    <Triggers>

        <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" />

    </Triggers> 

</asp:UpdatePanel>

<asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick"></asp:Timer>

后端代碼:


protected void Timer1_Tick(object sender, EventArgs e)

{

    // your code to refresh after some interval

}


查看完整回答
反對 回復 2021-08-07
  • 2 回答
  • 0 關(guān)注
  • 346 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號