I can see the result when entering anything in text field. The result does go to the DIV I want. However, I look at the source code for the page, I don't see the replacement element.
For example, I enter 'aaaaaaaaaaaaaaaa', click submit button, I see the result as You entered aaaaaaaaaaaaaaaa; But right click to open source, I don't see its html element
Because I use Accordion in other place, Accordion doesn't work well because JavaScript doesn't see the html elements returned from Action.
What shall I do to fix it?
The View
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<h2>Home Page</h2>
<%using (Ajax.BeginForm("Index", new AjaxOptions { UpdateTargetId = "HomeResult", InsertionMode = InsertionMode.Replace }))
{ %>
<%= Html.TextBox("query", null, new {size=40}) %>
<input type="submit" value="Home Submit" />
<%} %>
<div id="HomeResult">
<h2>Home result goes here.</h2>
<%Html.RenderPartial("PartialResult", ViewData.Model); %>
</div>
The Controller Action
public ActionResult Index()
{
if (Request.IsAjaxRequest())
{
ViewData["Message"] = "Partial View Logon";
return PartialView("PartialResult", Request.Params.Get("query"));
}
return View();
}
The Partial Result View
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<div>
<% if (Model != null) %>
<% { %>
<h1>
You entered <%= Model.ToString() %>
</h1>
<% } %>
</div>