Reputation: 1224
I have one drop downlist and text box in my view. now i have to set selected value of dropdownlist to textbox using jquery. i should not post back. i am learning mvc3 . so give me optimal way of doing it.
Upvotes: 1
Views: 7733
Reputation: 1038740
If you don't want to postback you will need to use javascript. For example if you use jQuery you could subscribe to the .change()
event of the dropdown and set the value of the textbox:
$(function() {
$('#id_of_your_drop_down').change(function() {
var selectedValue = $(this).val();
$('#id_of_your_text_box').val(selectedValue);
});
});
I would also recommend you going through the getting started tutorials in the jQuery documentation as this is quite basic functionality.
Upvotes: 3