Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear Friends, a very good morning to everyone.

am working on Asp.net,C#,SqlServer 2005.

My Requirement is I have a Textbox to Search the data from Gridview...its working fine.

now I need to add space in Textbox after entering 2 letters in Textbox.

for example I need to Search like this.....

MS 651
AT 258
XY 701
IY 532

I need a single Space after two characters like this MS 651...so that I can Search the data easily.

for displaying capital letters i gave textbox css as
text-transform:uppercase;
its working fine.

But I need a single space after two characters entered in TEXTBOX.

Please help me,

THANKS.
Posted

1 solution

use a field validator and write a regular expression (regex) to solve your problem.
here is link for regex class of .net
http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx[^]

and your patren would be something like this

string pattern = @"[A-Za-z][A-Za-z]\s[0-9]{6}";

[]=single occurrence from this set
\s= white space
{X}=total length is X (dont use this if the digits after space can vary).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900