In ASP.NET MVC 3 application I use Ajax.BeginForm to post writed text to controller.
@using (Ajax.BeginForm(\"Post\", \"Forum\", new {threadId = Model.Thread
It is a much nicer solution when you give your form an Id and then attach the submit event in a separate javascript file (using jQuery) and handle the post there
html:
@using (Ajax.BeginForm("Post", "Forum", new {threadId = Model.Thread.Id }, new {id = "formid" }))
{
...
Javascript:
$("#formid").submit(function (e) {
e.preventDefault();
if ($(this).valid()) {
$.ajax({
type: "POST",
url: $(this).attr('action'),
data: $(this).serialize(),
success: function (result) {
//do your success logic
}
});
}
});