当我更改DropDownList中的选择时,PartialView会通过GET请求进行更新。通过jQuery html()函数更新PartialView时,返回的html是正确的,但是当它在浏览器中显示时,它是不正确的。例如,PartialView中的某些复选框应该被启用,但即使返回的html说它们应该是,它们仍会被禁用。当我在浏览器中执行视图源时,html永远不会更新。
我有点困惑。想法?
Search.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>
答案 0 :(得分:2)
没关系,我明白了。我没有正确使用控件的属性。因此,它给出了标记没有改变的错觉。