0

I am trying to make my website update its text in realtime (or periodically), but i have had no luck so far. I am quite unexperienced with HTML, and thus i have no idea what to do. I am currently getting an often changing global string which i put into my Textbox, but the only way i managed to get the box to update is by making a button calling an empty event. Using a timer in my behind to constantly call the event didn't work.

<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">


    <asp:Button ID="Start" runat="server" Text="Start" OnClick="Program_Start" />
    <asp:Button ID="Refresher" runat="server" OnClick="Refresh" Text="Refresh text" />
    <input type="Text" name="textin" placeholder="Input" data-toggle="tooltip" id="textin" runat="server" />
    <asp:Button ID="submit_button" runat="server" OnClick="Submit_button" Text="Submit" UseSubmitBehavior="true" />
    <br />
    <asp:Literal runat="server" ID="textout" />
    <script>
        $(document).ready(function () {
            $(window).keydown(function (event) {
                if (event.keyCode == 13) {
                    event.preventDefault();
                    return false;
                }
            });
        });
            var intervalID = setInterval(document.getElementById("Refresher").click(), 50);
    </script>
</asp:Content>
Sorpl3x
  • 3
  • 2
  • 1
    I'd steer clear of UpdatePanel. They're extremely cumbersome, don't give you a lot of control, and cause difficult to debug issues. You're going to be better off either implementing your own AJAX polling, or taking advantage of SignalR to push updates from the server side to the client. – mason Oct 09 '19 at 13:30
  • I showed some examples of how to implement real time UI updates in [this question](https://stackoverflow.com/questions/25829343). – mason Oct 09 '19 at 13:58
  • Make sure the ClientIDMode on 'Refresher' is `static`. – wazz Oct 09 '19 at 19:30

0 Answers0