先定义枚举
public enum CustomValidationType
{ Integer,
Double,
String,
Date,
Currency,
PostCode,
CID,
Email,
Url,
IP
}
再定义属性
public CustomValidationType Type
{
get
{
object obj = ViewState["Type"];
if (obj==null) return CustomValidationType.String;
return (CustomValidationType)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
if (value == CustomValidationType.CID) MaxLength = CIDCount;
else if (value == CustomValidationType.PostCode) MaxLength = PostCodeCount;
else if (value == CustomValidationType.IP) MaxLength = IPCount;
else if (value == CustomValidationType.Date) MaxLength = DateCount;
else MaxLength = 0; }
}
public enum CustomValidationType
{ Integer,
Double,
String,
Date,
Currency,
PostCode,
CID,
Email,
Url,
IP
}
再定义属性
public CustomValidationType Type
{
get
{
object obj = ViewState["Type"];
if (obj==null) return CustomValidationType.String;
return (CustomValidationType)ViewState["Type"];
}
set
{
ViewState["Type"] = value;
if (value == CustomValidationType.CID) MaxLength = CIDCount;
else if (value == CustomValidationType.PostCode) MaxLength = PostCodeCount;
else if (value == CustomValidationType.IP) MaxLength = IPCount;
else if (value == CustomValidationType.Date) MaxLength = DateCount;
else MaxLength = 0; }
}
{
None,
OnlyDate,
OnlyNumber,
OnlyDecimal
}
________________________________________________________________________----
private vType _vType;______________________________________________________________________________
public vType VType
{
get{return _vType;}
set{_vType = value;}
}______________________________________________________________________
switch(_vType)
{
case vType.OnlyNumber:
...........................
判断得呆吗应该重写什么函数
switch(_vType)
{
case vType.OnlyNumber:
...........................
????
再一个项目中添加一个 servercontrol (.ascx)