MVC 3 CheckBox value OnChange, resubmit form - asp.net-mvc-3

I have a form with a checkbox in it, a textbox and a button. Whenever the button is clicked, it resubmits the form with whatever is in the textBox and checkBox. But whenever the checkBox changes, I also want it to resubmit the form. How can I do this?

You could add a bit of javascript that fires on the checkbox change, the jQuery below would do it -
$('#gosubmit').change(function () {
//submit form
});

Related

Kendo UI treelist hide button

I am using Kendo UI TreeList & Grid for jquery. I want to hide a command button based on row values. In grid, I attached dataBound event to evaluate the model value and show/hide command button, below codes works fine
dataBound:function(e){
var delButton = e.container.find(".k-grid-Delete");
if (...) delButton.hide();
}
For TreeList, the same code seems also fine. However, when I add inline edit featrue, the same codes works differently.
When click "Edit" or "Add", the grid stay the original visible status, but treelist show all the button.
When click "Cancel", I triggered dataBound event in cancel event so the UI can be refreshed, then the grid show correctly but treelist still show all the buttons even if the dataBound is executed with correct logic.
Does anybody know how to resolve this issue?
Thanks,
Ziff Dai

Kendo Grid - Pop up Editor issue

We are using pop up editor in the Kendo Grid control to edit the record.
My kendo grid has the below extra Controls as below.
Kendo dropdownlist
Div control
Add button
Remove button
A dropdown which has list of values that user will select and press the ADD button which is next to it.
then those values will be added to div control dynamically at runtime.
click on update in the editor, My controller updation action is getting fired.
Now i want to remove the items from the div tag using the Remove button. this time my controller update method is not firing.
I suspect that the changes in div is not firing the change event as the div control items dynamically added and removed.
How can i trigger the change event in the Remove button click function in jquery once i removed the div elements.
Please help me on this, trying this since 2 weaks.

How to hide/show JQGrid inline navigation button from javascript

Hide and show Add and Cancel button programmatically in JQGrid
You can make Add and Cancel button hidden of visible in the same way like any other elements on the HTML page. You can use jQuery.show, jQuery.hide or jQuery.css with "display", "none" or "display", "" parameters. Thus the only thing which you need is to get DOM elements which represent the buttons. You can get the elements by id for example.
jqGrid assigns ids to all standard buttons. The ids of buttons added by inlineNav will be build from grid id as prefix and strings "_iladd" (for Add button), "_iledit" (for Edit button), "_ilsave" (for Save button) and "_ilcancel" (for Cancel button). So if you have the grid with id="mygrid" then $("#mygrid_iladd").hide() can be used to hide the Add button and $("#mygrid_ilcancel").hide() to hide the Cancel button. To hide both buttons you can use $("#mygrid_iladd,#mygrid_ilcancel").hide().

Readonly NumericTextBox - disable the click event that shows the hidden input

We are using a Kendo NumericTextBox widget to display a calculated value to the user. We want the value shown to change as the viewmodel changes, but we do not want the user to be able to edit the value.
We have tried:
- disabling the widget. This disables user interaction, as required, but it does not allow the value to be updated by the view model.
- setting the widget as readonly. This allows the value to be updated, and does not allow the user to change the value directly, but the look of the widget changes when the user clicks on it.
We are trying to find a way to have something in between these two, where the value can be changed programmatically, but not by the user. And where there is no visible effect when the user clicks on the widget.
Is this possible with a Kendo NumericTextBox?
Edit: The issue is that changes to the viewmodel are sent back to the server by serializing the form, and disabled inputs don't get included in the form serialization. This is not an issue with the widget itself, as pointed out by CodingWithSpike.
The widget seems to update fine when set on the viewmodel, and the widget is disabled.
See this example.
<input data-role="numerictextbox"
data-format="c"
data-min="0"
data-max="100"
data-bind="enabled: isEnabled,
value: selectedNumber">
<button type="button" data-bind="click: up">Incrament</button>
...
<script>
var viewModel = kendo.observable({
selectedNumber: 0,
isEnabled: false,
up: function () { viewModel.set("selectedNumber", viewModel.selectedNumber + 1); }
});
kendo.bind($("#example"), viewModel);
</script>
Disable the widget when rendering the page to the user - this will still show updated values when they are re-calculated from other input. Then re-enable the widgets just before serializing the form back to the server.

MVC3 Restricting validation to the submitted form only

I have a view with two forms on it. Each form is marked like this:
Html.BeginForm("Details", "Forum", new { page = Model.PagedList.CurrentPage }, FormMethod.Post)
And each form has its own input button (type="button").
My problem is, when I click the button for one of the forms, the validation errors for the other form are added to the ModelState, so ModelState.IsValid == false.
How can I limit the scope of the validation to just the form I am clicking a button on?
Use Shared View instead to control your validations on different form.

Resources