当我更改 DropDownList 中的选择时,PartialView 会通过 GET 请求进行更新。通过 jQuery html() 函数更新 PartialView 时,返回的 html 是正确的,但是当它显示在浏览器中时它是不正确的。例如,PartialView 中的某些复选框应该启用,但即使返回的 html 显示它们应该启用,它们仍保持禁用状态。当我在浏览器中查看源代码时,html 永远不会更新。
我有点困惑。想法?
搜索.aspx
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Search
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<script type="text/javascript">
$(document).ready(function () {
$("#Sections").change(function () {
var section = $("#Sections").val();
var township = $("#Townships").val();
var range = $("#Ranges").val();
$.get("Search/Search?section=" + section + "&township=" + township + "&range=" + range,
function (response) {
$("#cornerDiv").html(response)
});
});
});
</script>
<h2>Search</h2>
<%--The line below is a workaround for a VB / ASPX designer bug--%>
<%=""%>
<% Using Ajax.BeginForm("Search", New AjaxOptions With {.UpdateTargetId = "searchResults", .LoadingElementId = "loader"})%>
Township <%= Html.DropDownList("Townships")%>
Range <%= Html.DropDownList("Ranges")%>
Section <%= Html.DropDownList("Sections")%>
<div id="cornerDiv">
<% Html.RenderPartial("Corners")%>
</div>
<input type="submit" value="Search" />
<span id="loader">Searching...</span>
<% End Using%>
<div id="searchResults"></div>
</asp:Content>