本文介绍了使用C#验证文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家晚上好............
我只需要一个代码来验证文本框,该文本框不得超过200个字符.
谁能上前
Good evening to everyone............
I just need a code to validate a textbox that should not allow more than 200 characters.
Can anyone step forward
推荐答案
TextBox ctrl = sender as TextBox;
if (ctrl.Length > 200)
{
ctrl.Text = ctrl.Text.Substring(0,200);
}
labelCtrl.Text = string.Format("{0} of 200 characters", ctrl.Text.Length);
这篇关于使用C#验证文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!