Get value from hidden field of ASP.Net in Javascript
<pre><code>&lt;body onload="timer()"&gt;
        &lt;style type="text/css"&gt;
        #time{
        font-size:50pt;
        }
        #body 
        {
            background-color:#F3F3F3;
        }
        &lt;/style&gt;
        &lt;script type="text/javascript"&gt;
            var digiclock = document.getElementById("&lt;%= HiddenFieldMinutes.ClientID %&gt;").value;
            i = 0;
            function timer() {
                var digiformat = "";
                if (i &gt; 3599) {
                    var H = Math.floor(i / 3600);
                }
                else {
                    var H = 0;
                }

                var M = i - (H * 3600)

                if (M &gt; 59) {
                    M = Math.floor(M / 60)
                }
                else {
                    M = 0
                }
                var S = i - (M * 60)
                if (H &lt; 10) {
                    H = "0" + H;
                }
                if (M &lt; 10) {
                    M = "0" + M;
                }
                if (S &lt; 10) {
                    S = "0" + S;
                }

                document.getElementById('time').innerHTML = H + ":" + M + ":" + S;
                setTimeout('timer()', 1000);
                i++;
            }
        &lt;/script&gt;
            &lt;table style="background-color:#F3F3F3;"&gt;
                &lt;tr&gt;
                &lt;td&gt;&lt;div&gt;&lt;center&gt;&lt;p style="font-family:Calibri;font-size:1.8em;color:#104E8B;"&gt;Total Elapsed Time&lt;/p&gt; &lt;/center&gt;&lt;/div&gt;
                &lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;
                &lt;td&gt;&lt;div id="time"&gt;&lt;center&gt;90&lt;/center&gt;&lt;/div&gt;
                &lt;/td&gt;&lt;/tr&gt;
                &lt;tr&gt;
                &lt;td&gt;
                &lt;center&gt;
                &lt;form id="Form1" runat="server"&gt;
                &lt;asp:HiddenField ID="HiddenFieldMinutes" runat="server" Value="" /&gt;
                    &lt;asp:Button ID="btnStop" runat="server" Text="Stop" 
                        style="width:150px;height:30px;font-weight:bold;background-color:#104E8B;color:White;border:1px solid" 
                        onclick="btnStop_Click" /&gt;&lt;/form&gt;&lt;/center&gt;
                        &lt;input id="HiddenTaskname" type="hidden" value="123" runat="server" /&gt;
                    &lt;/td&gt;&lt;/tr&gt;
            &lt;/table&gt;
</code></pre>

<p></p>

<p>As you see above , i m trying to create a clock which starts from specified time provided by the user. I m storing the starting time period in the hidden field. The Code behind of this page load of this page is as follow:-</p>

<pre><code>protected void Page_Load(object sender, EventArgs e)
    {
        HiddenFieldMinutes.Value = null;
        if (! IsPostBack)
        {
            //Checking for any query string
            if (Request["Code"] != null)
            {
                _elapsedNonProdTimeEntryID =Convert.ToInt32 (Request["Code"].ToString());
                _starttime = _nonProduction.GetStartTimeOfActiveTImeEntryID(_elapsedNonProdTimeEntryID);

                TimeSpan elapsedtimespan = System.DateTime.Now.Subtract(_starttime);
                string hh = elapsedtimespan.Hours.ToString();
                string mm = elapsedtimespan.Minutes.ToString();
                string ss = elapsedtimespan.Seconds.ToString();
                _differenceOfTimeSpan = hh + ":" + mm + ":" + ss;                    
                HiddenFieldMinutes.Value = _differenceOfTimeSpan;
                //ScriptManager.RegisterStartupScript(this, this.GetType(), "CloCkTImer", "javascript:timer(); ", true);                    
            }
        }
    }
</code></pre>

<p>But when i m debugging i m getting error on this line .<code>var digiclock = document.getElementById("&lt;%= HiddenFieldMinutes.ClientID %&gt;").value;</code></p>

<p>Please help me to improve this webpage and full fill my requirement.</p>
