[英]ASP.NET MVC: Populating Derived Strongly Typed View with Base Strongly Typed View
[英]Asp.net MVC multiple uploads with strongly typed view?
我有一個強類型化為對象的視圖,例如,假設一個汽車對象。 汽車對象具有名稱和描述。 我希望能夠上傳動態數字圖像,也許使用Jquery上傳插件,將其與car對象以及圖像的一些元數據(如拍攝日期)一起使用。 那么,如何使用強類型視圖和動態圖片上傳數量呢?
我在網上找到了一些示例 ,但是它們使用了新表單的創建,因此圖像將執行不同的操作。 有沒有辦法讓汽車模型和上傳的圖像數據一起執行? 這可能嗎?
[HttpPost]
public ActionResult Add(Car car, IEnumerable<HttpPostedFileBase> files)
{
return View();
}
@using (Html.BeginForm()) {
<div>
<fieldset>
<legend>Car information</legend>
<div class="editor-label">
@Html.LabelFor(m => m.Name)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.Name)
@Html.ValidationMessageFor(m => m.Name)
</div>
<div class="editor-label">
@Html.LabelFor(m => m.Description)
</div>
<div class="editor-field">
@Html.TextBoxFor(m => m.Description)
@Html.ValidationMessageFor(m => m.Description)
</div>
<label for="file1">Filename:</label>
<input type="file" name="files" id="file1" />
<label for="file2">Filename:</label>
<input type="file" name="files" id="file2" />
<p>
<input type="submit" value="Save" />
</p>
</fieldset>
</div>
}
在進行動態上傳時,以下內容將在ASP.net MVC 3中為您提供幫助。
現在做以下事情
希望這一步可以幫助您創建解決方案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.