Reputation: 1691
I have two textboxes, one isfor 'program' and the other for 'description'. I have a predefined set of programs and it is associated descriptions in the database.
Example : For program named 'Test' it has the description as 'Valid' in the DB Table
For example, when enter a program name in the program textbox as 'Test', its associated description 'Valid' should be populated automatically to the 'Description' TextBox on losing focus from the 'Program' TextBox.
How can I achieve this using asp.net mvc
Upvotes: 0
Views: 1898
Reputation: 78667
A combination of the textbox blur event and using an ajax call.
$('#program').blur( function(){
//make ajax call to action method to get the description for this value
$.get(yourActionUrl, { data : $(this).val() }, function(response) {
//set the value of description text box
$('#description').val( response );
});
});
Upvotes: 6