Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I refer to ASP.NET Controls in Javascript?
    primarykey
    data
    text
    <p>I'm working on My First ASP.NET Application. I have created some text boxes and buttons, and added client-side validation to the text boxes. I now wish to set and clear the enabled property of the buttons according to the contents and validity of the text boxes.</p> <p>I have studied the questions and answers <a href="https://stackoverflow.com/questions/2155508/user-controls-in-asp-net-prefixing-string-to-child-controls-causing-problem-to-re">here</a>, <a href="https://stackoverflow.com/questions/384867/properly-referencing-controls-in-asp-net-user-controls-in-javascript">here</a>, <a href="https://stackoverflow.com/questions/2246595/grabbing-asp-net-controls-in-javascript">here</a> and <a href="https://stackoverflow.com/questions/1112274/refering-to-controls-through-javascript-function">here</a>, and the best I have been able to manage is this...</p> <pre><code>&lt;script language="javascript" type="text/javascript"&gt; function SetButtonSensitivity() { var label = document.getElementById("&lt;%= lblResult3.ClientID %&gt;"); var button = document.getElementById("&lt;%= btnDone.ClientID %&gt;"); if (Page_ClientValidate()) { label.Text = "valid"; button.disabled = false; } else { label.Text = "not valid"; button.disabled = true; } } &lt;/script&gt; </code></pre> <p>I can tell this script is invoked when I tab away from the textbox fields, as the error messages are emitted by the client-validate, but the script has no effect on the button or the label.</p> <p>Can anyone see what I have overlooked?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload