我有這種局部視圖來搜索發佈者,但是當我以另一種形式與另一個動作結果一起使用它時,它會響應其他像這樣的內容。如何在創建其他內部模型時進行搜索
這個觀點是我的行動在未來一個
@using (Html.BeginForm("publisherslist",FormMethod.Get))
{
<input type="text" id="q" name="q"/>
<input type="submit" />
}
@foreach (var i in Model)
{
@Publisher.Name
<br />
}
,我呈現在另一種觀點
@model ELibrary_Search_Engine.BookModels.Book
@using (Html.BeginForm("Create", null, FormMethod.Post, new {enctype= "multipart/form-data" }))
{
<div class="form-horizontal">
<div class="form-group">
@Html.LabelFor(model => model.Name, new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name)
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CategoryID, "CategoryID", new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownList("CategoryID", String.Empty)
@Html.ValidationMessageFor(model => model.CategoryID)
</div>
</div>
<input type="file" id="file" name="file" />
<br />
<label>Choose Publisher:</label>
<br />
@Html.Action("publisherslist")
<input type="submit" value="Create" />
</div>
}
我想啓用出版商搜索的局部視圖
您是否必須按照此方法搜索發佈者?我的意思是我們可以建議改進嗎?請列出所提供的'views',這樣我們就不會做出錯誤的假設。 'Model'在'publisherslist'視圖中返回什麼? 「Html.RenderPartial(」發佈者「,我)是做什麼的? – Searching
我糾正了你說的對不起,因爲它很糟糕 我想第一個formmethod發佈者列表在創建視圖中呈現 –
NP沒關係。看起來您正嘗試在創建表單中搜索發佈商,然後將其與其他詳細信息一起提交。在當前的設置中,它可能不起作用,因爲搜索(即使它是正確的)只返回純文本。你有沒有考慮過使用'ajax.get'來代替搜索發佈者。 'Book'模型是否有'PublisherName'屬性來綁定? – Searching