i have a jquery Dialog in a partial view:
@model JQueryDialogPoc.Models.FeedBack
@using (Ajax.BeginForm(\"GiveFeedback\", \"Home\", null, new AjaxOptions { HttpM
You haven't really shown what scripts have you included in your page, how does the markup of your view looks like, etc... things allowing us to reproduce your problem. Usually what I do with such questions is to try to provide a full example that I think might be close to what you are trying to do.
Model:
public class FeedBack
{
[Required]
[Display(Name = "Feedback")]
public string Feedback { get; set; }
}
Controller:
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult GiveFeedback()
{
return PartialView(new FeedBack());
}
[HttpPost]
public ActionResult GiveFeedback(FeedBack model)
{
if (!ModelState.IsValid)
{
return PartialView(model);
}
return Json(new { result = "Thanks for submitting your feedback" });
}
}
View (~/Views/Home/Index.cshtml
):
@Html.ActionLink("Give feedback", "GiveFeedback", null, new { id = "feedbackLink" })
Remark: obviously the scripts I have shown in this Index view have nothing to do there. They should be moved to the layout and the inline script moved into a separate javascript file and referenced in the layout. I just included them to show what scripts are required for the example to work.
And finally we have the partial containing the feedback form (~/Views/Home/GiveFeedback.cshtml
):
@model FeedBack
@using (Ajax.BeginForm("GiveFeedback", "Home", null, new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "feedback", OnSuccess = "onSuccess" }, new { id = "popForm" }))
{
-
@Html.EditorFor(x => x.Feedback)
@Html.ValidationMessageFor(x => x.Feedback)
}