locked
How to refresh my page every 1s without user notice that or lost his\her unsaved work? RRS feed

  • Question

  • User-2071692902 posted

    Hi all,

    how to as I mention above without user notice that or lost.

    I used this code but it is very Very annoying

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

    And also this is same 

    <script>//To refresh the page.
    function refreshPage() {
        location.reload();
    }
    </script>

    Any help will be appreciated

    Sunday, November 25, 2018 4:28 PM

Answers

  • User61956409 posted

    Hi Omanxp45-1,

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

    It will take the control of a page away from the user when it is refreshing document, obviously it will affect user performance.

    If you'd like to refresh the content with a specified time interval and do not want user notice that, you can use asp:UpdatePanel control with asp:Timer control.

    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" Interval="1"></asp:Timer>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <%--your content here--%>
                <%=DateTime.Now %>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" />
            </Triggers>
        </asp:UpdatePanel>
    </div>

    Besides, if you'd like to implement real-time web functionality, you can use ASP.NET SignalR.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 26, 2018 5:49 AM

All replies

  • User-471420332 posted
    You can refresh particular div witout refreshing page.
    Sunday, November 25, 2018 4:50 PM
  • User-2071692902 posted

    mazhar khan india

    You can refresh particular div witout refreshing page.

    You mean to add  to #conDivID my code ?

    <script>//To refresh the page.
    function refreshPage() {
        location.reload(#conDivID);
    }
    </script>
    Sunday, November 25, 2018 10:15 PM
  • User61956409 posted

    Hi Omanxp45-1,

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

    It will take the control of a page away from the user when it is refreshing document, obviously it will affect user performance.

    If you'd like to refresh the content with a specified time interval and do not want user notice that, you can use asp:UpdatePanel control with asp:Timer control.

    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:Timer ID="Timer1" runat="server" Interval="1"></asp:Timer>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <%--your content here--%>
                <%=DateTime.Now %>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="Timer1" />
            </Triggers>
        </asp:UpdatePanel>
    </div>

    Besides, if you'd like to implement real-time web functionality, you can use ASP.NET SignalR.

    With Regards,

    Fei Han

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 26, 2018 5:49 AM