文本框上的验证 [英] validations on textbox

查看:64
本文介绍了文本框上的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
如何在silverlight4.0中对两个文本框执行比较验证?
(但我在asp.net中知道这一点.)

谢谢
nareshrajuu

hi all,
how to perform a compare validation on two textboxs in silverlight4.0?
(but i know this in asp.net.)

thanks
nareshrajuu

推荐答案

//this is validation method
       protected bool Validation()
       {
           bool returnValue = false;
           try
           {
               if (string.IsNullOrEmpty(txt1.Text))
               {
                   Label1.Text = "Please Enter txtbox1 value";
                   returnValue = false;
                   txt1.Focus();
               }
               else if (string.IsNullOrEmpty(txt2.Text))
               {
                   Label1.Text = "Please Enter txtbox2 value";
                   returnValue = false;
                   txt2.Focus();
               }
               else if (txt1.Text != txt2.Text)
               {
                   Label1.Text = "Doesn't match the txtbox1 and txtbox2";
                   returnValue = false;
                   txt1.Focus();
               }
               else
               {
                   returnValue = true;
               }
           }
           catch (Exception Ex)
           {
               Label1.Text=Ex.Message
           }
           return returnValue;
       }
//in button click event or textchanged event you can write like this

 if (Validation())
                {
//do something here.....
                }


这可能对您有帮助
Silverlight 4:数据验证-每日技巧-部分1 [ ^ ]
This may help you
Silverlight 4 : Data Validation - Tip of the Day - Part 1[^]


非常感谢您的答复,它将完成我的任务.
teamfoundationserver中有什么方法可以根据日期来比较是否验证teamfoundationserver中的两个字段?
thank u very much to your reply.it will fulfill my task.
is there any way in teamfoundationserver to compare the validates a two fields in teamfoundationserver based on date?


这篇关于文本框上的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆