1

问题是,当我尝试在主视图内呈现部分视图时,它仅用部分视图内容替换主视图窗口,而不是在主视图内显示部分视图

搜索表单.html

@model IEnumerable<MobileFirmDirectory.Models.User>
@using (Html.BeginForm("SearchResultsPar", "User", FormMethod.Post))
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
@using (Ajax.BeginForm("SearchResultsPar", 
                       new AjaxOptions 
                       {
                           UpdateTargetId = "SearchResults",
                           InsertionMode = InsertionMode.Replace,
                           HttpMethod="GET"
                       })) 
{
    <fieldset><legend>Firm Directory Search:</legend>
      <div style="float:left;margin:10px;">
        <table style="padding:20px 0px 0px 20px;">
          <tr>
            <td style="font-weight:bold; font-size:12pt;" >Last Name:</td>
            <td style="width:300px">@Html.TextBox("lname")</td>
          </tr>
          <tr>
            <td style="font-weight:bold; font-size:12pt;">First Name:</td>
            <td>@Html.TextBox("fname")</td>
          </tr>
          <tr>
            <td style="font-weight:bold; font-size:12pt;">Title Name:</td>
            <td>@Html.TextBox("titletext")</td>
          </tr>
          <tr>
            <td style="font-weight:bold; font-size:12pt;">Office:</td>
            <td>@Html.DropDownList("Office", ViewBag.officeList as SelectList, "Select Office") </td>
          </tr>
          <tr>
            <td></td>
            <td>
              <table style="float: right;">
                <tr>
                  <td>
                    <input type="submit" value="Search" onclick="return submitcheck();" />
                  </td>
                  <td>
                    <input type="reset" value="Clear" />
                  </td>
                </tr>
              </table>
            </td>
          </tr>
        </table>
      </div>

      <div id="SearchResults" style="float:right;margin:10px;padding:10px;border:dotted 5px black;">
        @{Html.RenderPartial("SearchResultsPartial");}
      </div>
    </fieldset>
}

控制器动作

public ActionResult SearchResultsPar(string lname, string fname, string titletext, string office)
{
    **Code is hidden intentionally**
    return PartialView("SearchResultsPartial",obj);
}
4

0 回答 0