I have a form in DoComment.ascx:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<DT.KazBilet.Objects.PublicationComment>" %>
<div class="wrap">
<h4>Comment</h4>
<%using (Ajax.BeginForm("DoComment", "Publication", new {id = Model.Publication.OID, parentId = Model.OID},new AjaxOptions()))
{%>
<%=Html.TextAreaFor(x=>x.Text) %>
<%-- <textarea style="width: 100%; height: 152px;"></textarea>--%>
<input type="submit" value="Publish" class="btn ok_btn" />
<%}%>
</div>
This is my controller’s action:
public JsonResult DoComment(PublicationComment model, int id, int parentId)
{
PublicationRepository.SaveComment(User.Identity.Name,id, parentId, model.Text);
return Json(new {
Message = "You comment on moderation"
});
}
I want that user clicks on Publish button then show popup window where will be written text from Message.
Can you help me(some code)?
Thanks.
You could subscribe to the
OnSuccessjavascript event in the AJAX options and then show the JSON result you have retrieved the way you like (new window, div, …):and then you would define the
onSuccessjavascript function. Depending on whether you use jQuery or MicrosoftAjax the implementation of this function might slightly vary and more specifically the way to retrieve the JSON result.For example if you are using MicrosoftAjax (obsolete now):
and if you are jQuery: