i want to display time using hidden variable in a page,but
when i click button that page that hidden variable loosing
its value.i m sending the code also.

<script type="text/javascript" language="javascript">
var tick=0;

window.onload = function() {
//debugger

if(document.getElementById("hdnTicker").value != "")

tick =
parseInt(document.getElementById("hdnTicker").value);
setInterval("Timer()",1000);


}

function Timer()
{
//debugger
document.getElementById("hdnTicker").value = tick++;
//alert(document.getElementById("hdnTicker").value);

document.getElementById("lblTimeSpent").innerHTML = "0." + tick;
if(tick == 30)
{
//message or redirect to result window
alert('time is out');
//clearTimeout();
}
} </script>


<form id="form1" runat="server">
<div>
<table>
<tr>
<td>
<asp:Label ID="lblTimeSpent" runat="server"
Visible="true" ForeColor="Blue" ></asp:Label>
</td>

<td>
<%-- <asp:textbox EnableViewState="true"
id="hdnTicker" runat="Server"
style="visibility:hidden"></asp:textbox>--%>
</td>
</tr>
<tr>
<td>
<asp:Button ID="btn" runat="server"
Text="hi" OnClick="btn_Click" Height="30px" Width="60px" />
</td>
</tr>
</table>




<%--<asp:HiddenField ID="txt" runat="server"
Visible="true" />--%>

</div>
</form>
<input type="hidden" id="hdnTicker" name="hdnTicker"
enableviewstate="true" runat="server" />

Answer Posted / vishnu tiruttani

You can use <%=Request("hdnVariable")%> to use that in the
javascript. So when the value is posted to server it can be
accessed.

Is This Answer Correct ?    0 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What companies use javascript?

470


What is difference between javascript and jscript?

450


What are the data types available in javascript? Explain

485


What is the result of below given line of code in java script? 5+4+'7'?

517


What is the real name of JavaScript?

567






What is a scope in javascript?

461


What is argument objects in javascript?

513


What is null in programming?

529


how to run the servlet in tomcat

1657


What is the difference between sessionstate and viewstate?

504


Which software is best for javascript?

541


What is let keyword in typescript?

546


How many functions are there in javascript?

485


Explain how to detect the operating system on the client machine?

497


What does undefined value mean in javascript?

576