服务器端验证(c#asp.net)

如何为空控件应用服务器端验证??

例如:-

我有一个ID为"txtusername"的文本框..
我想对此控件的空值应用验证..


我可以单击提交"按钮进行检查..


就像if(txtusername.text.trim()== string.Empty)
{
(应该在此处编写什么代码?)
}

我想在弹出窗口中显示一条消息,例如请输入用户名"
多谢!!! :)
也可以,如果您也可以帮助告诉我其他验证信息..
(例如有效的日期时间,电子邮件地址,整数值等...)

How to apply server side validation for an empty control???

for e.g:-

i have a textbox having id "txtusername"..
i want to apply validation for the empty value for this control..


i can check it on clicking the submit button..


like if(txtusername.text.trim()==string.Empty)
{
(what code should be written here?)
}

i want to show a message in a popup window like "Please enter username"
thanks a lot!!! :)
also if u can help tell me for the other validations too..
(like for valid datetime,email address,integer value etc...)



 1 条回答

C#