小编Kel*_*nis的帖子

使用Ajax表单的MVC 4 Razor更新foreach循环

从哪里开始...我可以在互联网上找到类似的东西,但是它们似乎永远不会以我想要做某事的具体方式工作.我尝试了有部分观点和没有部分观点但收效甚微.

快速概述:我有一个带有Ajax表单的强类型视图.在表单下面,我有一个重复代码块的foreach循环.我需要能够从表单选项(过滤器)更新代码块.

这是我的视图,'FindATeacher.cshtml',因为它目前(尝试了许多不同的想法后):

@model Teachers.Models.OmniModel
@{
    ViewBag.Title = "FindATeacher";
    Layout = "~/Views/Shared/_Layout.cshtml";

}
<h2>Find a Teacher</h2>
@using (Ajax.BeginForm("FilterTeachers", "Home", new AjaxOptions { HttpMethod = "Post", OnSuccess = "onSuccess" }))
{
    <div id="ContentFilter">
        <div class="filterLabels">
            <p>Search by Name</p>
            <p>Filter By Instrument</p>
            <p>Filter By City</p>
        </div>
        <div class="filterObjects">
            <p>
                <input type="text" id="nameTXT" />
                <button type="submit" id="findButton">find</button>
            </p>
            <p>@Html.DropDownList("InstrumentID", (SelectList)Model.Instruments, "-- Select an Instrument --", new { id = "instrumentDD" })</p>
            <p>@Html.DropDownList("CityID", (SelectList)Model.Cities, "-- Select a City --", new { id = "cityDD" …
Run Code Online (Sandbox Code Playgroud)

ajax asp.net-mvc jquery razor asp.net-mvc-4

9
推荐指数
1
解决办法
3万
查看次数

标签 统计

ajax ×1

asp.net-mvc ×1

asp.net-mvc-4 ×1

jquery ×1

razor ×1