In my view I have a label which displays my email. Next to it there's a button that opens up a text box where you can enter a new email.
In my 'Account' controller I have a method called 'UpdateEmail' that is reading a query string parameter called 'email'. This method records the new email in the database.
Upon a click of the Save button a block of javascript code invokes this method asynchronously:
var urlString = "/account/updateemail/?email=" + model.Email;
$.getJSON(urlString, function (data)
{
// Do your stuff here such as hide the div
// with the text box and Save and Cancel buttons.
}
{
// Do your stuff here such as hide the div
// with the text box and Save and Cancel buttons.
}
routes.MapRoute("AccountUpdateEmail", "account/updateemail", new {controller = "Account", action = "UpdateEmail"});