var page;

$(document).ready(function () {
    Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("ControlReady", []);

    page = $(
        "<div><label for='Name'>First Name</label><input type='text' id='Name'></div>" +
        "<div><label for='LastName'>Last Name</label><input type='text' id='LastName'></div>" +
        "<div><input type='button' id='submit' value='Send to NAV'></div>"
        );
});

function MethodCall(request) {
    switch (request.method) {
        case "start":
            $("#controlAddIn").append(page);
            $("#submit").click(function () {
                Microsoft.Dynamics.NAV.InvokeExtensibilityMethod("ControlEvent", [
                    {
                        Event: "submit",
                        FirstName: $("#Name").val(),
                        LastName: $("#LastName").val()
                    }
                ]);
            });
            break;
    }
};
