2
是否有可能有一個Html.TextBoxFor
html helper綁定到多個字符串?我的意思是說,你有一個輸入,用戶可以用用戶名或電子郵件登錄。基本上,類似如下:c#mvc textboxfor多個字符串
@Html.TextBoxFor(x => x.UserName || x.Email) // this does not work obviously,
// but you got the idea
model.cs
...
[Required]
public string UserName {get; set;}
[Required]
public string Email {get; set;}
// btw, the required attribute may cause a problem therefore I can
// remove or ignore them while validating
嗯這不是我一直在尋找,但謝謝你的提示:) – Shaokan