Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Changing DIV value using jquery Asp.net MVC

Changing DIV value using jquery Asp.net MVC

Guest post 
I 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();
    }


my ajax call would be

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.



This post first appeared on Asp.netSourceCodes, please read the originial post: here

Share the post

Changing DIV value using jquery Asp.net MVC

×

Subscribe to Asp.netsourcecodes

Get updates delivered right to your inbox!

Thank you for your subscription

×