I have a simple webgrid which displays list. I also have a combobox which contains few items. I want that when user changes the selection, the changed value should be posted to the server. How can I do this?
Any code snippets would be helpful.
I have a simple webgrid which displays list. I also have a combobox which contains few items. I want that when user changes the selection, the changed value should be posted to the server. How can I do this?
Any code snippets would be helpful.
Auto-postback in Web Forms was accomplished with some JavaScript. This is not out-of-the-box in MVC, but simple enough to do on your own.
Assuming you have jQuery:
$(document).ready(function() {
$('#someCheckBox').change(function() {
$('#yourFormId').submit();
});
});
This is "closest" to how classic Web-Forms work; basically does "When a checkbox with the ID of 'someCheckBox' is checked or unchecked, submit the form with id 'yourFormId'. You can of course change this to your needs.
This wasn't included out-of-the-box due to most developers favoring AJAX calls instead of full-blown post-backs, which I would encourage you to do if possible. What might be more preferable is:
$(document).ready(function() {
$('#someCheckBox').change(function() {
$.ajax(/*make an AJAX call*/);
});
});
You implement it with ajax actions and javascript You can find a example here