Changing DIV value using jquery Asp.net MVC
Guest postI have one div division
"myname"name="myname">myvalue
i am Changing value of "myvalue" with jquery
how can i pass myvalue to my controller.
Solution
create a controller get the value by $("#myname").text();
and pass it into the controller like this
for example this is my controller
[HttpPost]
public void UpdateTask(TaskModel tmdl)
{
sDBSEntities dbOBj = new sDBSEntities();
Task tObj = dbOBj.Tasks.Single(x => x.ID == tmdl.ID);
tObj.Name = tmdl.Name;
tObj.Description = tmdl.Description;
tObj.DateUpdated = DateTime.Now;
dbOBj.SaveChanges();
}
vartmdl = {
ID: $("#hdnId").val(),
Name: $("#txtName").val(),
Description: $("#txtDesc").val()
};
$.ajax({
type: 'POST',
url: '/Task/UpdateTask',
data: tmdl,
cache: false,
success: function (result) {
clearAll();
alert("Updated Successfully");
location.reload();
},
error: function () {
alert('Err');
}
});
}
Users Please post your solution too.