获得textBox 对应的Long/Int/Boolean等值
2017-02-21 18:23:01 访问(2465) 赞(0) 踩(0)
/// <summary>
/// 获得textBox 对应的 long 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public long TextBoxGetLongValue(TextBox txt)
{
string strValue = txt.Text;
long theResult = 0;
if (long.TryParse(strValue, out theResult))
return theResult;
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的long值。");
}
/// <summary>
/// 获得textBox 对应的 int 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public int TextBoxGetIntValue(TextBox txt)
{
string strValue = txt.Text;
int theResult = 0;
if (int.TryParse(strValue, out theResult))
return theResult;
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的int值。");
}
/// <summary>
/// 获得textBox 对应的 ulong 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public ulong TextBoxGetULongValue(TextBox txt)
{
string strValue = txt.Text;
ulong theResult = 0;
if (ulong.TryParse(strValue, out theResult))
return theResult;
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的ulong值。");
}
/// <summary>
/// 获得textBox 对应的 float 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public float TextBoxGetFloatValue(TextBox txt)
{
string strValue = txt.Text;
float theResult = 0;
if (float.TryParse(strValue, out theResult))
return theResult;
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的float值。");
}
/// <summary>
/// 获得textBox 对应的 double 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public double TextBoxGetDoubleValue(TextBox txt)
{
string strValue = txt.Text;
double theResult = 0;
if (double.TryParse(strValue, out theResult))
return theResult;
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的double值。");
}
/// <summary>
/// 获得textBox 对应的 Boolean 值
/// </summary>
/// <param name="txt"></param>
/// <returns></returns>
public bool TextBoxGetBooleanValue(TextBox txt)
{
string strValue = txt.Text;
if (strValue == CommonConfig.True.ToString())
return true;
else if (strValue == CommonConfig.False.ToString())
return false;
else
throw ExceptionFunctions.NewExceptionMessage("txt[" + txt.ClientID + "]" + ".Text = " + strValue + ",不是有效的bool值。");
}
标签:
获得textBox 对应的Long/Int/Boolean等值 


上一条:
下一条:
相关评论
发表评论