开发者

ASP.NET MVC - PartialView html not changing via jQuery html() call

开发者 https://www.devze.com 2022-12-24 08:54 出处:网络
When I change the selection in a DropDownList, a PartialView gets updated via a GET request. When updating the PartialView via the jQuery html() function, the html returned is correct but when it disp

When I change the selection in a DropDownList, a PartialView gets updated via a GET request. When updating the PartialView via the jQuery html() function, the html returned is correct but when it displayed in the browser it is not correct. 开发者_JAVA百科For example, certain checkboxes within the PartialView should become enabled but they remain disabled even though the html returned says they should be. When I do a view source in the browser the html never gets updated.

I'm a little perplexed. Thoughts?

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>


Never mind, I figured it out. I wasn't using a property of a control correctly. So, it was giving the illusion that the markup wasn't changing.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号