I'm new to MVC and I'm trying to update my page after I submit my form; but it's not working. I'm only trying to hide the form, and show the contents of a div OnSuccess.
My code is:
<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>
}
Any alternate solutions / ideas are most welcome.
Thanks in advance!
See Question&Answers more detail:os