我刚接触MVC,试图在提交表单后更新页面,但是没有成功。我只是想隐藏表单,并在OnSuccess中显示一个div的内容。
我的代码如下:
<script type="text/javascript">
$(document).ready(function () {
$('#confirmation').hide();
});
function MessageConfirmation() {
$('#confirmation').show('slow');
$('#contactForm').hide('slow');
}
</script>
@using (Ajax.BeginForm("Index", new AjaxOptions { OnSuccess = "MessageConfirmation" }))
{
<fieldset id="contactForm">
<legend>Message</legend>
<p>
@Html.Label("Email", "Email"): @Html.TextBox("Email")
</p>
<p>
@Html.Label("Subject", "Subject"): @Html.TextBox("Subject")
</p>
<p>
@Html.Label("Message", "Message"): @Html.TextArea("Message")
</p>
<p>
<input type="submit" value="Send" />
</p>
</fieldset>
<p id="confirmation" onclick="MessageConfirmation()">
Thanks!!!
</p>
}
任何其他解决方案/想法都非常欢迎。 提前致谢!
MS Ajax.*
辅助工具的理由吗?你的理由是否也适用于 MVC4? - kyle.stearns