Pages

Sunday, May 16, 2010

Useful Regular Expression

For Alpha numeric :-

^[a-zA-Z0-9_]+$

Examples:-

ROOT, ROOT_One

For Numeric with Comma:-

^\$?(\d{1,3},?(\d{3},?)*\d{3}(.\d{0,3})?|\d{1,3}(.\d{2})?)$

Examples:-

1,111,11  

Numeric with 3 Digits(Compulsory with 0’s) :-

^[0-9]{3}$

Examples:-

000-999 integers where your has to enter three digits

001,003,343,999….

 

You can check any regular expression in the following URL it is a web based regular expression checker. Very useful.

http://www.rubular.com/

Thursday, April 8, 2010

Setting Foucs on a Textbox when the Silverlight page loads

 

I found this on silverlight.net, and was able to get it to work for me by adding a call to System.Windows.Browser.HtmlPage.Plugin.Focus() prior to calling RegularTextBox.Focus():

 

private void UserControl_Loaded(object sender, RoutedEventArgs e)
   {       
      System.Windows.Browser.HtmlPage.Plugin.Focus();
      RegularTextBox.Focus();
   }