當我將驗證規則添加到Model類時,可以將錯誤消息添加到它,但僅限一種語言;我怎麼能添加更多的語言翻譯爲單個屬性的錯誤消息? 我要寫更多的類「副本」還是存在一個更好的方法來實現它?在ASP.NET MVC 3模型的驗證規則中,如何添加用更多語言翻譯的錯誤消息?
Public Class Movie
Public Property ID() As Integer
<Required(ErrorMessage:="Title is required")>
Public Property Title() As String
<Required(ErrorMessage:="Date is required")>
Public Property ReleaseDate() As Date
<Required(ErrorMessage:="Genre must be specified")>
Public Property Genre() As String
<Required(ErrorMessage:="Price Required"), Range(1, 100, ErrorMessage:="Price must be between $1 and $100")>
Public Property Price() As Decimal
<StringLength(5)>
Public Property Rating() As String
End Class
您是否嘗試過使用資源文件? – AntLaC