.val() with asp.net textbox
I am trying to use the following code to change the data in textboxes when a combobox selection changes:
// handle combo list change
$('#comboAffiliateTypesList').change(function() {
var theValue = $('#comboAffiliateTypesList').val();
if (theValue < 0 ) {
$('#txtAffiliateType').val('Required').css({'color':'#C0C0C0'});
$('#txtSortIndex').val('Required').css({'color':'#C0C0C0'});
} else {
$('#txtAffiliateType').val($('#comboAffiliateTypesList :selected').text()).css({'color':'black'});
$('#txtSortIndex').val(theValue).css({'color':'black'});
}
});
This code does populate the textbox on the screen with the correct values. But when the data is posted back on my submit button, the .text values for the textboxes are the old values.
I read somewhere on this site that if the textbox name and ID are the same the val function does not work. Is that correct? If so what can I do in an asp.net environment where it sets the name and ID for the textboxes the same?
TIA
John