回答

2

你可以使用一個視圖模型:

public class MyViewModel 
{ 
    public string Text { get; set; } 
} 

將被傳遞給視圖:

public ActionResult Index() 
{ 
    var strings = new[] { "String 1", "String 2", "String 3" }; 
    var model = new MyViewModel 
    { 
     Text = string.Join(Environment.NewLine, strings) 
    }; 
    return View(model); 
} 

渲染:

@model MyViewModel 
... 
@Html.TextAreaFor(x => x.Text) 
0

將字符串保存在屬於視圖模型的IList中。

相關問題