@model WebApplication2.Models.Person
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script>
$(document).ready(function () {
$("#Button1").click(function () {
$.ajax({
url: "/Home/Method",
type: 'POST',
data: $("#Form2").serialize(),
success: function (response) {
document.getElementById("Firstname").value = response
alert(response);
},
error: function (xhr) {
alert("Something went wrong, please try again");
}
});
});
});
</script>
@using (@Html.BeginForm("Index", "Home", FormMethod.Post, new { id="Form1" }))
{
<div class="jumbotron">
@Html.TextBoxFor(model => model.Firstname)
<br />
<br />
<br />
</div>
}
<input id="Button1" type="submit" value="SubmitBtn" />
<br />
@using (@Html.BeginForm("Index", "Home", FormMethod.Post, new { id = "Form2" }))
{
<div class="jumbotron">
@Html.TextBoxFor(model => model.Firstname)
<br />
<br />
<br />
</div>
}
No comments:
Post a Comment