2013-01-10 40 views
1

我需要將一個字符串列表發送到asp網絡mvc控制器中的方法。我怎樣才能做到這一點?控制器中的Asp .Net方法獲取字符串列表

我想在我的控制我的方法看起來是這樣的:

public ActionResult CutFile(string[] filenames, string target) 

可選我可以在字符串數組參數更改爲這樣的事情:

public ActionResult CutFile(IEnumerable<string> filenames, string target) 

回答

3

您需要發送的數據在這種格式:

<input type="text" name="filenames[0]" value="A"/> 
<input type="text" name="filenames[1]" value="B"/> 
<input type="text" name="filenames[2]" value="C"/> 

<input type="text" name="target" /> 
+0

如果我使用jQuery與ajax做一個職位的方法,我該怎麼做在? – Alecu

+1

只是通過一個字符串列表: {文件名:['A','B','C'],目標:'X'} – MuriloKunze

相關問題