@{
ViewBag.Title = "Home Page";
}
@using (Html.BeginForm("Index", "Form", FormMethod.Post, new { id = "Index_form",
role = "form" }))
{
<button type="submit" class="btn btn-primary btn-block" id="indexs-button"
style="display: none">被呼叫的按鈕</button>
}
<button type="submit" class="btn btn-primary" id="index-button">呼叫的按鈕
</button>
@section scripts
{
<script type="text/javascript">
$('#index-button').click(function () {
show();
alert("test");
});
function show() {
document.getElementById("Index_form").submit();
}
</script>
}
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Form()
{
Response.Write("<script language=javascript>alert('123');</" + "script>");
return View("Index");
}