i am trying to implement a simple add operation using MVC Ajax
My code is as follows:
Public Class Model
{
public int number1{get;set;}
public int
Update: Based on your model:
[HttpPost]
public int TestAjax(Model mymodel)
{
return mymodel.number1 + mymodel.number2;
}
And in your HTML assuming you are referencing the model:
@model Model
replace your inputs with this accordingly:
@Html.TextBoxFor(model => model.number1)
@Html.TextBoxFor(model => model.number2)
You have to validate that the user only types integer valid values in your textboxes with javascript.
You need to set the name
attribute in your html element:
<input type="text" id="txtbox2" name="txtbox2" />