From the view this is the call to the controller,
$('#Submit').click(function () {
var params = { Id: $('#ID').val() };
$('#Summary').html("Loading...");
$.ajax({
url: '<%= Url.Action("Summary", "Home") %>',
data: params,
success: function (html) {
$('#Summary').html(html);
},
cache: false
});
});
On the controller, I have this after the action finishes execution,
ViewData["Message"] = displayMessages.ToArray();
Return view("userctrl");
“userctrl” is the user control to display messages and the code here looks like this
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
if (ViewData.ContainsKey("Message")) { %>
<div class="Message">
<%= ViewData["Message"] %>
</div>
<% } %>
Now this usercontrol is then returned to the view, as shown above. this works fine if there is a single string but as an array , little more coding is needed in terms of casting it. Please let me know in user control how can I code it ?
Return string from your Action instead of TempData, Something like