How can I update a partial view that is displayed as dialog?
I have to send error messages from the controller to the partial view that is displayed as a dialog, i.e in other words I want to upd开发者_高级运维ate the dialog with the error messages
Please, I need an example how to do that?
Not quite sure I understand you fully, if you are just asking how you pass a list of errors to a partial view to display them then here is a simple example:
Dialog.ascx
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<ICollection<string>>" %>
<% if (Model.Count > 0) { %>
<h3>The following errors have occurred:</h3>
<ul>
<% foreach (var err in Model) { %>
<li><%= err %></li>
<% } %>
</ul>
<% } else { %>
<h3>No errors were found</h3>
<% } %>
Controller
public ActionResult Validate()
{
List<string> errors = new List<string>();
// validate and build up errors
return RenderPartial("Dialog", errors)
}
精彩评论