In my ASP.NET form I have one text box, which value gets changed every 10 seconds using javascript code. Initial value of text box is 10, and gets higher by 5 on every 10 seconds event. When I click my submit button, and try to access myTextBox.Text property, I get value of 10, instead of current value in my text box. What is the problem here, why I can't see the current value written in my text box<'
My client side code:
var d = 0;
var interval = 0;
function initializeMe() {
d = document.getElementById("<%= time.ClientID %>").innerHTML;
interval = self.setInterval("clock()", 10000);
}
function clock() {
if (d > 0) {
document.getElementById("<%= time.ClientID %>").innerHTML = d;
document.getElementById("<%= txtTime.ClientID %>").value = d.toString();
d = d - 1;
}
else {
d = "Message";
document.getElementById("<%= vrijeme.ClientID %>").innerHTML = d;
document.getElementById("<%= txtVrijeme.ClientID %>").value = "0";
}
}
<form id="form1" runat="server">
<div>
<asp:Label ID="time" runat="server"></asp:Label>
<asp:TextBox ID="txtTime" runat="server"></asp:TextBox>
<asp:Button ID="submit" runat="server" Text="Sumbmit"
onclick="sumbit_Click"/>
</div>
</form>
My server code
int value = 700 - Convert.ToInt16(txtTime.Text);//But here server reads wrong value