public string InsuredName
{
get;
set;
}
public string Card_No
{
get { return this.card_No; }
set { this.card_No = value; }
}
这里我有两个专业,CardNo
只需要一些InsuredNames
。当用户输入InsuredName然后我想去数据库并检查它是否有Card_No验证如果是,那么我想要根据需要验证它不是,我尝试远程验证,但它无法正常工作
答案 0 :(得分:0)
private string insuredName;
private bool cardNoRequiresValidation;
public string InsuredName
{
get {return insuredName;}
set { cardNoRequiresValidation = DoesCardNoRequiresValidation(Value); insuredName = value;}
}
public string Card_No
{
get { return this.card_No; }
set { cardNoRequiresValidation ? ValidateCardNo(value) : card_No = value; }
}
private bool DoesCardNoRequiresValidation(string insuredName)
{ //if requires validation
// return true;
//else
//return false;
}
private void ValidateCardNo(string cardNo)
{
//execute validation logic
}