0

I'm trying to send new values to an HTML table after a page has already been rendered. New values are sent 'x minutes' after the page has already been rendered on the client end, and are displayed in a new column in the html table.

The HTML is created with C# code with the code behind file, and initiated via a function call inside the actual html on the aspx page.

htmlStr = "<tr><td>" + market[0].runners[marketCounter].runnerName + "</text></td>" + "<td>" + marketOdds[0].runners[marketCounter].lastPriceTraded.ToString() + "</td>" + "<td>" + "</td>" + "<td>" + NewValuesin10Mins()???????????????? + </td></tr>;
  • You cannot fetch data from server side once the page is been loaded, you will have to use jquery/ajax for this purpose. take a look at this thread https://stackoverflow.com/questions/17862381/getting-data-from-aspx-to-jquery-ajax – Abdul Hannan Jan 19 '20 at 07:13
  • @Abdul Hannan Thank you! – QuietWorld Jan 19 '20 at 12:53

1 Answers1

0

if you want to modify the client side after render, try to use the function RegisterStartupScript, the script block added by the RegisterStartupScript method executes when the page finishes loading but before the page's OnLoad event is raised

public String GetNewKey()
{
    String _string_key = String.Empty;
    Guid _guid = Guid.NewGuid();
    foreach (char _char in Convert.ToBase64String(_guid.ToByteArray()))
    {
        _string_key += char.IsLetterOrDigit(_char) ? _char.ToString() : string.Empty;
    }
    return _string_key;
}

public void RunScript(String _script)
{
    String function = @"<script type='text/javascript'> $(function () { " + _script + " }); </script>";
    this.ClientScript.RegisterStartupScript(_page.GetType(), Utilities.GetNewKey(), function, false);
}
Josue Barrios
  • 440
  • 5
  • 10