用于多个字符串的c#mvc文本框
是否可以将用于多个字符串的c#mvc文本框,c#,asp.net-mvc,textbox,C#,Asp.net Mvc,Textbox,是否可以将Html.TextBoxForHtml帮助程序绑定到多个字符串?我的意思是,假设您有一个输入,用户可以使用用户名或电子邮件登录。基本上如下所示: @Html.TextBoxFor(x => x.UserName || x.Email) // this does not work obviously, // but you got the idea model.cs ... [Requi
Html.TextBoxFor
Html帮助程序绑定到多个字符串?我的意思是,假设您有一个输入,用户可以使用用户名或电子邮件登录。基本上如下所示:
@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
不要将文本框绑定到任一属性。只需在操作中处理代码,以检查用户名和电子邮件
如果您正在创建登录表单,则不会更新任何属性,因此无需绑定。hmm这不是我想要的,但感谢您提供的提示:)