public ActionResult New(string id)
{
// On commence l'écriture en partant d'un
// message vide.
// On n'actualise que les champs de saisie
// de New.ascx.
ViewData.Model = id;
return View();
}
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="New.ascx.cs" Inherits="Messenger.Views.Messages.New" %>
<form method="post" action="<%= Url.Action("Send", new { id = ViewData.Model } ) %>">
<textarea name="messagetext" cols="28" rows="3"></textarea>
<br />
<%= Html.SubmitButton("send", "Send") %>
</form>
; (function() {
var successFunction = function (data, textStatus) {
jQuery('#panel').html(data.toString());
};
var errorFunction = function(XMLHttpRequest, textStatus, errorThrown) {
// Make sure to display the server side error page
if (XMLHttpRequest !== undefined) {
jQuery('body').html(XMLHttpRequest.responseText);
return;
if (textStatus !== undefined) {
alert(textStatus);
if (errorThrown !== undefined) {
alert(errorThrown);
jQuery.fn.ajaxify = function() {
return jQuery(this).each(function() {
// AJAX links
return jQuery(this).click(function() {
try {
jQuery.ajax({url:this.href, type:'get', dataType:'html',
cache:false, success:successFunction,
error:errorFunction });
} catch(e) {
alert(e);
return false;
});
})();
$(document).ready(function() { $('#actions a').ajaxify(); });