0
我無法獲得此表單,它返回組件中顯示的簡單字符串,而是寫入新頁面。Ajax.BeginForm返回到新頁面,而不是Visual Studio中的HTML DIV
代碼在這裏,我是新手,但它似乎是遵循我讀的指導方針?我已經嘗試過在列表外部的div上,並且還包裝了列表對象,如圖所示。
任何想法,這讓我很生氣。
它從postGreSQL中返回一個搜索字符串,但是在新頁面上正確顯示它,而不是在我想要的div中。
@{
ViewBag.Title = "Search";
}
<hgroup class="title">
<h1>@ViewBag.Title.</h1>
<h2>@ViewBag.Message</h2>
</hgroup>
<fieldset>
<legend>Find Address</legend>
@using (Ajax.BeginForm("Display", "Home",
new AjaxOptions
{
HttpMethod = "POST",
InsertionMode = InsertionMode.InsertAfter,
UpdateTargetId = "divAddressSearchResults"
}))
{
<div id="divAddressSearchResults">
<ol>
<li>
@Html.Label("House Number")
@Html.TextBox("_HouseNumber", "", new { @style = "text-transform:uppercase" })
</li>
<li>
@Html.Label("House Name")
@Html.TextBox("_HouseName", "", new { @style = "text-transform:uppercase" })
</li>
<li>
@Html.Label("Post Code")
@Html.TextBox("_PostCode", "", new { @style = "text-transform:uppercase" })
</li>
</ol>
<button>Search</button>
</div>
}
</fieldset>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js")" type="text/javascript"></script>
你有'jquery.unobtrusive-ajax.min.js'在你的項目? – TechVision
我確實,對不起,我會添加我錯過的代碼。謝謝。 – Hairy