Call



InitCall helper initiates a server call that can be executed using awe.oc(name, opt) js function, similar to awe.open(name, opt) used for opening popups
CallDemo/Index.cshtml
@Html.Awe().InitCall("callHi").Url(Url.Action("SayHi")).Success("echo")
@Html.Awe().InitCall("callName").Url(Url.Action("SayName")).Parent("txtName", "name").Success("echo")
@Html.Awe().InitCall("callName2").Url(Url.Action("SayName")).Parent("txtName", "name")

<p>
<button type="button" class="awe-btn" onclick="awe.oc('callHi')">Click to call</button>
</p>
<p>
<button type="button" class="awe-btn" onclick="awe.oc('callName', { params: { id: 15 } })">Call with parameters</button>
<button type="button" class="awe-btn foo">Call 2</button>
</p>

@Html.Awe().TextBox("txtName").Placeholder("write a name here").Value("Art Vandelay")

<script>
function echo(res) {
alert(res);
}

$(function() {
$(document).on('click', '.foo', function() {
var btn = $(this);
var xhr = awe.oc('callName2', { params: { id: 20 } });

$.when(xhr).done(function(res) {
var msg = $('<span> ' + res + '</span>');
btn.after(msg);
setTimeout(function () {
msg.fadeOut(function () { msg.remove(); });
}, 1000);
});
});
});
</script>
Demos/Helpers/CallDemoController.cs
using System.Web.Mvc;

namespace AwesomeMvcDemo.Controllers.Demos.Helpers
{
public class CallDemoController : Controller
{
public ActionResult Index()
{
return View();
}

public string SayHi()
{
return "server says hi";
}

public string SayName(string name, int id)
{
return "my name is " + name + "; id = " + id;
}
}
}