मैं अपने रूप मिल गया है के रूप मेंAsp.Net MVC Ajax.BeginForm अजाक्स
<div id="contact-form" class="hidden" title="Online Request Form">
@Using (Ajax.BeginForm("Contact", "Main",
Nothing,
New AjaxOptions With {.UpdateTargetId = "status", .HttpMethod = "post"},
New With {.id = "contactUs"}))
@<div>
@Html.LabelFor(Function(m) m.Name)<br />
@Html.TextBoxFor(Function(m) m.Name)<br />
@Html.LabelFor(Function(m) m.Phone)<br />
@Html.TextBoxFor(Function(m) m.Phone)<br />
@Html.LabelFor(Function(m) m.Email)<br />
@Html.TextBoxFor(Function(m) m.Email)<br />
@Html.LabelFor(Function(m) m.Question)<br />
@Html.TextAreaFor(Function(m) m.Question)<br />
@Html.LabelFor(function(m) m.Security)<br />
@Html.TextBoxFor(Function(m) m.Security)<br />
<noscript>
<input type="submit" name="submit" value="Ok" />
</noscript>
@Html.ValidationSummary("Oops, please correct the errors.")<span id="status">@TempData("status")</span>
</div>
End Using
</div>
इस प्रकार है और मैं एक jQuery-यूआई मोडल विंडो
<script>
$(function() {
// Open the modal dialog from the div.contact-us click event
$('#contact-us').click(function() {
$('#contact-form').dialog('open');
return false;
});
// Manage the modal dialog behavior.
$('#contact-form').dialog({
modal: true,
autoOpen: false,
buttons: {
Cancel: function() {
$(this).dialog('close');
},
Ok: function() {
$('form#contactUs').trigger('submit');
}
}
});
});
</script>
में खोलकर कर रहा हूँ जब मैं "ठीक" बटन पर क्लिक करें, यह उचित नियंत्रक से पोस्ट कर रहा है, लेकिन यह AJAX
''# fix the StackOverflow code coloring issue.
<HttpPost()>
Function Contact(ByVal contactForm As Models.ContactForm) As ActionResult
ViewData("Testimonials") = Helpers.GetTestimonials
If ModelState.IsValid Then
''# Submit the email
TempData("status") = "Thank you, we will be in touch"
Else
''# Return False
TempData("status") = "Oops, please correct the errors."
End If
If Request.IsAjaxRequest Then
Return Content(TempData("status").ToString)
Else
Return View("Index")
End If
End Function
के माध्यम से पोस्टिंग नहीं है क्या मैं गलत कर रहा हूँ? बाद मैं फ़ॉर्म सबमिट करेंगे, मेरी यूआरएल http://example.com/Main/Contact जो मुझसे कहता है कि IsAjaxRequest = false
संपादित
यहां तक कि जब मैं jQuery ui को "ठीक" बटन का उपयोग नहीं करते और केवल फार्म के लिए <input type="submit" name="submit" value="Ok" />
जोड़ने के लिए, प्रपत्र अजाक्स
उस दिन की प्रतीक्षा कर रहे हैं जब स्टैक ओवरफ्लो उचित रूप से रेजर सिंटैक्स रंग दे सकता है। –