2011-08-25 13 views
0

您好我想爲「產品」模型,創建形式,其自身包含的「圖片」的收集,以這種方式:命名上傳控件像TextboxFor在asp.net mvc的

<%:Html.TextBoxFor(x=> x.ProductID)%> 
..... 
...... 

<%Htm.EditorFor(x=>x.Pictures)%> 

而且我做了圖片編輯器模板:

<input type="file" name="?" id="?"> 
<%:Html.TextBoxFor(y=>y.PictureName) 

正如你所知道的MVC每個集控這樣的給出了一個獨特的名字:

<input type="text" id="Picture[0].PictureName" .... 

但我希望它也用於上傳控件,我的意思是爲每個圖片的上傳控件命名。

有什麼辦法嗎?

回答

0

是的。在您的編輯模板中:

<input type="file" 
     name="@ViewData.TemplateInfo.GetFullHtmlFieldName("")" 
     id="@ViewData.TemplateInfo.GetFullHtmlFieldId("")" />