I have an ASP.NET control with some text fields and a checkbox. I would like to modify the checkbox state using JavaScript based on the values present in the text fields after page load.
How can I reliably read the text field values in JavaScript? I saw this answer but it didn't help:
<asp:TextBox Text='<%# Bind("something") %>' ID="txtSomething" runat="server">
</asp:TextBox>
<script type="text/javascript">
alert($('#<%= txtSomething.ClientID %>').val());
</script>
This doesn't work; VS tells me that "txtSomething
is not declared. It may be inaccessible due to its protection level."
How else can I refer to that text box in JavaScript?