To achieve this task, I rely on JavaScript, although I prefer using jQuery
for its ease of use. My approach involves keeping my HTML and JavaScript code separate, listening for the on change event only after all controls have been loaded into the DOM.
An example of HTML markup for a text box with a custom label element:
<input id="ItnScanCaseCode" name="ItnScanCaseCode" type="text" value="" />
<label id="lblSelectedProductName">Test Label Text</label>
Here's the jQuery script to assign an on change event listener:
$(document).ready(function () {
$('#ItnScanCaseCode').change(function () {
$('#lblSelectedProductName').text('sam');
});
});
If you wish to encapsulate the label text changing functionality in a separate function method, you can do so like this, but the previous approach works well enough for me:
$(document).ready(function () {
function yourEventMethod() {
$('#lblSelectedProductName').text('sam');
};
$('#ItnScanCaseCode').change(function () {
yourEventMethod();
});
});
I trust that this explanation is helpful.