JavaScript problem please HELP!

Discussion in 'HTML / PHP / JavaScript / CSS' started by albanello, May 12, 2014.

  1. I have a JavaScript Stop Watch that starts when I press the "Update" button. Pressing the "Update" button" ALSO starts the post to the server. The Stop Watch is running while the Server is doing its work. I am timing how long it takes to execute SQL Stored Procedure's. The Stop Watch works perfectly on its own I can start, stop and reset it with no problem!
    What seams to be happening is when the HTML page is displayed the "MyStopWatch" label writes over what I wrote to it in the <body onload="MyNew();">
    I can not figure out how to display the Stop Watch time at the point when the local computer receives the Postback.
    ********
    <asp:button id="btnUpdate" runat="server" Text="Update" CausesValidation="False" JSStartUpdate();return true;"></asp:button>
    Starts Stop Watch AND starts runat=server

    JSStartUpdate()
    Starts the Stop Watch timer

    <input type="text" id="MyStopWatch"/>
    Displays the Stop Watch time as it is running and SHOULD display the time at the point of postback

    <input type="hidden" id="myHiddenVal"/>
    Continuously stores the Stop Watch time as it is running

    <body onload="MyNew();">
    Is suppose to initialize "MyStopWatch" to the hidden field "myHiddenVal" value
    ********
    Operation sequence (as I understand)
    1) "btnUpdate" pressed
    2) "JSStartUpdate()" Starts Javascript Stop Watch timer
    3) "return true" allows start "runat=server"
    4) SQL Stored Procedure executes and other stuff at server
    5) Postback
    6) new HTML page displayed
    7) <body onload="MyNew();"> executes> Halts Stop Watch timer> display <input type="hidden" id="myHiddenVal"/> in "<input type="text" id="MyStopWatch"/>
    8) "<input type="text" id="MyStopWatch"/> writes its value which overwrite the value I wrote
    Step 8 is where I see the problem........IF my understanding of the sequence is correct
    Hope this is not too confusing, tried to simplify as much as possible.
    Hope someone can see problem.
    Thanks in advance
    Frank
     
  2. I got it to work by having the code-behind to write to a <asp:hidden> control then JavaScript writes that value to the MyStopWatch control
     
    RayH likes this.
  3. RayH

    RayH DiscountASP.NET Lackey DiscountASP.NET Staff

    Glad you found a solution.
     

Share This Page