Sunday, November 25, 2007

Microsoft Popfly

 

Popfly is the fun and easy way to build and share mashups, gadgets, and Web pages. It’s made up of online visual tools for building Web pages and mashups and a social network where you can host, share, rate, comment and even remix creations from other Popfly users.

Add some fun to your Facebook page, web site, or Windows Live Spaces page. You can easily spice up your Web site or blog with Popfly by adding customized games like Whack-a-mole or asteroids with pictures of your friends and family or create custom quizzes or polls that you can easily embed on your Web site.

Build a home page. You can build a custom home page, say for your school’s sports team and choose from over 150 different themes, 10 styles, and 30 unique color themes for a unique visual design. You can then easily add things like team photos, a team schedule from an RSS feed, video from previous games, Virtual Earth maps with directions to game locations and more, all without writing code.

Mix and re-mix photos and videos. Popfly makes it easy to create and share beautiful slideshows using pictures from Flickr, Windows Live Spaces, Facebook or to embed a podcast or a video player hosting videos from Soapbox or YouTube and share it on your Facebook profile, Windows Live Spaces page, or any Web page.

Unify your online personality. Popfly enables you to customize and stitch together your online persona in one place. You can create mashups that show what you dug on Digg.com, what you are buying or selling on eBay, you Halo 3 game scores, what Facebook events you’re attending, what your friends are doing on Twitter, and much more. 

In addition, Popfly offers a powerful web programming environment and social network so you can bring in new data sources, create new ways to display information, or even create and share full Visual Studio projects.

Tuesday, November 20, 2007

Selecting a single radio button inside a grid view

the below code will explain how to change your code for selecting a single radio button inside a grid view.

by default we can select multiple radio buttons inside a grid view.to make it a single selection we need to add a script..

below code explain that


  1 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID" DataMember="DefaultView" DataSourceID="SqlDataSource1"
  2 <Columns> 
  3 <asp:TemplateField> 
  4 <ItemTemplate> 
  5 <input type="radio" runat="server" id="rdOption" onclick="SelectOne(this,'GridView1')"  VALUE="rdo" /> 
  6 </ItemTemplate> 
  7 <HeaderStyle CssClass="Head" /> 
  8 <ItemStyle CssClass="Item" />
  9 </asp:TemplateField> 
 10
 11 <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" > 
 12 <HeaderStyle CssClass="Head" /> 
 13 <ItemStyle CssClass="Item" /> 
 14 </asp:BoundField> 
 15
 16 <asp:BoundField DataField="CategoryName" HeaderText="CategoryName" SortExpression="CategoryName" > 
 17 <ItemStyle CssClass="Item" /> 
 18 <HeaderStyle CssClass="Head" /> 
 19 </asp:BoundField> 
 20 </Columns> 
 21 </asp:GridView>


add the following javascript

  1 <script language="javascript"
  2
  3 function SelectOne(rdo,gridName) 
  4
  5    all=document.getElementsByTagName("input"); 
  6    for(i=0;i<all.length;i++) 
  7    { 
  8      if(all[i].type=="radio"
  9      { 
 10         var count=all[i].name.indexOf(gridName+'$ctl' ); 
 11         if(count!=-1
 12         { 
 13            all[i].checked=false
 14         } 
 15       } 
 16     } 
 17    rdo.checked=true
 18
 19 </script>


the Script will be called in the on click event of the radio button in the grid

Monday, October 01, 2007

The Write Less, Do More, JavaScript Library..Jquery



jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.

What jQuery Does

The jQuery library provides a general-purpose abstraction layer for common web scripting, and is therefore useful in almost every scripting situation. Its extensible nature means that we could never cover all possible uses and functions in a single book, as plug-ins are constantly being developed to add new abilities.

The core features, though, address the following needs:

1.Access parts of a page.

2.Modify the appearance of a page.

3.Alter the content of a page.

4.Respond to a user's interaction with a page.

5.Add animation to a page

6.Retrieve information from a server without refreshing a page.
(AJAX)

7.Simplify common JavaScript tasks.

more info -

http://jquery.com/
http://15daysofjquery.com/
http://jquery.com/blog/

Monday, September 24, 2007

Developer Extension To Mozilla

The Web Developer extension adds a menu and a toolbar to the browser with various web developer tools. It is designed for Firefox, Flock, Mozilla and Seamonkey, and will run on any platform that these browsers support including Windows, Mac OS X and Linux.

Monday, September 17, 2007


Speed up your web pages with YSlow a tool from Yahoo Developer Network

YSlow analyzes web pages and tells you why they're slow based on the rules for high performance web sites.

YSlow is a Firefox add-on integrated with the popular Firebug web development tool.

YSlow gives you:

* Performance report card
* HTTP/HTML summary
* List of components in the page
* Tools including JSLint

more info...

Thursday, September 06, 2007

Find string between and xml or html string

 
The following code can be usefull to search a string with in an html tag
 
private string ParseHtml(string strInput, string key)
{
string returnValue = string.Empty;

int startIndex = strInput.ToUpper().IndexOf("<" + key.ToUpper() + ">");

int endIndex = strInput.ToUpper().IndexOf("</" + key.ToUpper() + ">");

if(startIndex != -1 && endIndex != -1)

{

returnValue = strInput.Substring(startIndex + (key.Length + 2), endIndex - (startIndex + (key.Length + 2))).ToString();
}

return returnValue;

}

 


string str = "<from>jeebu@abc.com</from>";

MessageBox.Show(ParseHtml(str ,"from"));

will return jeebu@abc.com

Tuesday, August 14, 2007

Proud to be an indian

Celeberating 60th year of indian independence

Sunday, July 15, 2007

Web 2.0 Busy Dialog Box

The below created code will help in showing a loading form when a busy server process is going on

it will also disable all the controls in the form so that the server process is not interpreted.

All the javascript,css codes are embedded in js and css file

   1: <LINK href="style.css" type="text/css" rel="stylesheet">
   2: <SCRIPT language="JavaScript" src="loader.js"></SCRIPT>

Style.css


 



   1: BODY 
   2: { 
   3:     PADDING-RIGHT:  0px; 
   4:     PADDING-LEFT:   0px; 
   5:     PADDING-BOTTOM: 0px; 
   6:     MARGIN:         0px; 
   7:     PADDING-TOP:    0px 
   8: } 
   9:  
  10: #BackGroundFade 
  11: { 
  12:      DISPLAY: none; 
  13:      FILTER:  alpha(opacity=80); 
  14:      LEFT:    0px; 
  15:      WIDTH:   100%; 
  16:      POSITION: absolute; 
  17:      TOP: 0px; 
  18:      BACKGROUND-COLOR: #ffffff; 
  19:      opacity: 0.8 
  20: } 
  21:  
  22: #ForeGroundActive 
  23: { 
  24:    FILTER: alpha(opacity=60); 
  25:    BORDER-RIGHT: #000000 0px solid; 
  26:    BORDER-TOP: #000000 0px solid; 
  27:    LEFT: 0px; 
  28:    BORDER-LEFT: #000000 0px solid; 
  29:    WIDTH: 300px; 
  30:    BORDER-BOTTOM: #000000 0px solid; 
  31:    POSITION: absolute; 
  32:    TOP: 0px; 
  33:    HEIGHT: 300px; 
  34:    BACKGROUND-COLOR: #ffffff;
  35:    opacity: 0.8 
  36: } 
  37:  
  38: .LoadingText
  39: {
  40:   FONT-SIZE: 11px;
  41:   COLOR: #6c7473;
  42:   FONT-FAMILY: arial
  43: }
  44:  
  45: .Text
  46: {
  47:   FONT-SIZE: 11px;
  48:   FONT-FAMILY: arial;
  49:   COLOR: #6c7473
  50: }

Loader.js



   1: var loader = new Image();
   2: loader.src = "rollera.gif";
   3:   
   4: function Loading(loadingtext)
   5: {
   6:     BackGroundFade();
   7:     Fore_ground_panel_activate(loadingtext);
   8:     
   9: }
  10:  
  11: function Fore_ground_panel_activate(loadingtext)
  12: {
  13:     var fore_ground_panel;
  14:     var w = 300; 
  15:     var h = 300;
  16:     
  17:     this.fore_ground_panel = document.createElement ('DIV');
  18:     document.body.appendChild(this.fore_ground_panel);
  19:     this.fore_ground_panel.id = 'ForeGroundActive';
  20:  
  21:     var brSize        = this.getBrowserSize();
  22:     var bodyWidth    = brSize[0];
  23:     var bodyHeight    = brSize[1];
  24:     xc = Math.round((bodyWidth/2)-(w/2))
  25:     yc = Math.round((bodyHeight/2)-(h/2))
  26:     
  27:     this.fore_ground_panel.style.left = xc + "px";
  28:     this.fore_ground_panel.style.top  = yc + "px";
  29:     this.fore_ground_panel.style.display = 'block';
  30:     var HTML = "<table border=0><tr><td><img src='" + loader.src + "'>&nbsp;&nbsp;&nbsp;&nbsp;</td><td><p class=LoadingText><b>" + loadingtext + " </b></p></td></tr>"
  31:        this.fore_ground_panel.innerHTML =HTML;
  32:        
  33:    }
  34:  
  35: function BackGroundFade()
  36: {
  37:     var back_ground_panel;
  38:     var brSize;
  39:     var bodyWidth;
  40:     var bodyHeight;
  41:             
  42:     brSize        = this.getBrowserSize();
  43:     bodyWidth    = brSize[0];
  44:     bodyHeight    = brSize[1];
  45:                 
  46:     this.back_ground_panel = document.createElement('DIV');
  47:     this.back_ground_panel.id = 'BackGroundFade';
  48:     this.back_ground_panel.style.height = bodyHeight + 'px';;
  49:     document.body.appendChild(this.back_ground_panel);
  50:     this.back_ground_panel.style.display = 'block'
  51:     
  52: }
  53:  
  54: function getBrowserSize()
  55: {
  56:     var bodyWidth    ;
  57:     var bodyHeight  ;
  58:     
  59:     bodyWidth=    document.documentElement.clientWidth;
  60:     bodyHeight    =    document.documentElement.clientHeight;
  61:     
  62:     if (self.innerHeight)
  63:     { 
  64:         // all except Explorer 
  65:         bodyWidth    =    self.innerWidth; 
  66:         bodyHeight    =    self.innerHeight; 
  67:         
  68:     }  
  69:     else if (document.documentElement && document.documentElement.clientHeight) 
  70:     {
  71:         // Explorer 6 Strict Mode          
  72:         bodyWidth    =    document.documentElement.clientWidth; 
  73:         bodyHeight    =    document.documentElement.clientHeight; 
  74:     } 
  75:     else if (document.body) 
  76:     {// other Explorers          
  77:         bodyWidth    =    document.body.clientWidth; 
  78:         bodyHeight    =    document.body.clientHeight; 
  79:     } 
  80:     return [bodyWidth,bodyHeight];        
  81:         
  82: }
  83: function LoadDefault()
  84: {
  85:     var page_screen = document.getElementById('BackGroundFade');
  86:     page_screen.style.display = 'none';
  87: }
  88: function hideSelect()
  89: {
  90:     for (j=0; j<document.forms.length; j++) 
  91:     {
  92:         var theForm = document.forms[j]
  93:         for(i=0; i<theForm.elements.length; i++)
  94:         {
  95:         alert(theForm.elements.name)
  96:             if(theForm.elements.type == "select-one") 
  97:             {
  98:             theForm.elements.style.visibility = "hidden";
  99:             }
 100:         } 
 101:     }
 102: } 
 103:  
 104:  
 105:  
 106:     

the following code will set the attribute for calling the javascript indicationg a process is going on



   1: Button2.Attributes.Add("OnClick","javascript:Loading('loading');");


function BackGroundFade() 

will create a div tag and which covers the whole form so that the user cannot click on any controls



function Fore_ground_panel_activate(loadingtext);

will create div with the loading image ...we can change the caption of the text for each button click



Thursday, July 12, 2007

My community Credit Award


Friday, June 01, 2007

Google Mashup Editor - Mashup Framework and Tools

Google Mashup Editor is an AJAX development framework and a set of tools that enable developers to quickly and easily create simple web applications and mashups with Google services like Google Maps and Google Base. Google Mashup Editor is a great tool for grabbing information from feeds and letting users see and manipulate it.

Creating applications with Google Mashup Editor is simple and uses technologies you're familiar with. With our declarative XML tags, JavaScript, CSS, and HTML, you can build applications in less time and with less work. For advanced developers, Google Mashup Editor allows you to be more expressive by tapping into our JavaScript API.

more info
Google Mashup Editor Getting Started Guide

Sunday, May 20, 2007

My first smart phone application in visual studio 2005

What Is a Smartphone?

The worldwide mobile wireless industry is quickly moving from traditional, voice-based cellular phone services to combined voice and data services, as a result of increasing demand for mobile data access and the deployment of high-speed wireless data services utilizing a variety of wireless technologies.

Microsoft Smartphone refers to Microsoft’s platform for next-generation cell phones—basically a software architecture with Windows CE as the operating system, plus a rich set of applications such as Pocket Internet Explorer and Pocket Outlook and powerful software development tools such as .NET Compact Framework and Visual Studio 2005.




Visual Studio 2005 is the major multi-language IDE (Integrated Development Environment) for Windows applications. Both managed and unmanaged code of Windows desktop applications can be developed using Visual Studio 2005. It allows managed and unmanaged Pocket PC and Smartphone application programming targeting Windows Mobile devices. With the .NET Framework on their target systems or devices, developers can use a single set of .NET Framework classes in different languages,
with the same naming and calling convention, and similar syntax. In particular, mobile application developers can leverage their experience and programming techniques obtained from smart client application development with Visual Studio 2005, and the only difference is the class libraries: They will work with a subset of the desktop .NET Framework class libraries. Visual Studio 2005 (and the previous version,Visual Studio .NET) is the key element for rapid and high-performance .NET application development,testing, and deployment over various systems and devices.

.NET Compact Framework Type System
.NET languages such as Visual C# and Visual Basic are based on the same type system as the .NET Compact Framework and use the same class library. Thus, developers familiar with one .NET language (and therefore the .NET Compact Framework type system) can easily move to another .NET language.Every class in the .NET Compact Framework, including those with built-in value types, is directly or indirectly inherited from the System.Object class. Only single inheritance is allowed in the .NET Framework and .NET Compact Framework; a class cannot have more than one base classes. Any userdefined classes are inherited from the System.Object class if no base class is explicitly specified.

Windows Mobile 5.0 SDK for Smartphone
The Windows Mobile 5.0 SDK for Smartphone includes the Smartphone emulators (which are also in Visual Studio 2005), some command-lines tools, help files, header files, and libraries for native code development.
You can download the SDK from www.microsoft.com/downloads/
details.aspx?familyid=DC6C00CB-738A-4B97-8910-5CD29AB5F8D9&displaylang=en.

ActiveSync
You need to have Microsoft ActiveSync to connect your Smartphone device to your Windows PC.ActiveSync acts as the gateway between your PC and your Windows Mobile device so that you can easily transfer files or synchronize application data such as e-mail, a calendar, and so on. For Smartphone development, ActiveSync is needed by Visual Studio to transfer data between the development PC and the device or the emulator. You can download ActiveSync from www.microsoft.com/windows
mobile/activesync/default.mspx.

Types
There are two kinds of objects in the .NET Compact Framework: built-in value types and reference types. A value type is a primitive data type that holds only values. They are actually structures allocated on the stack. Reference types are instances of classes and must be created using the new keyword.

Generics
The .NET Compact Framework 2.0 and later support parametric polymorphism using generics.

To create an instance of a generic Stack object that holds a MyObj type in C#, you can do the following:
System.Collections.Generic.Stack myObj = new
System.Collections.Generic.Stack ();

Exception Handling
Exceptions are runtime errors that need to be handled to avoid program crashes. The .NET Framework and the .NET Compact Framework provide a built-in mechanism to handle exceptions using the wellknown



try.
{

}
catch
{
}

finally
{
}


Visual Studio 2005 will put your project into a solution, which is simply a collection of projects, one of which is designated as the “Startup” project. The Form Designer shows an image of a conceptual Smartphone with Form1
loaded into its screen. The form appears to be empty; no controls have been placed onto it. However, there is already a control named “mainMenu1” at the bottom of the form. Usually, all forms in Smartphone applications should have a Main Menu control for soft keys immediately under the screen of a Smartphone.The automatically generated project now has only two files: Form1.cs and Program.cs. Form1.cs is the
GUI interface with which a Smartphone user will interact, whereas Program.cs is the place where the.NET Compact Framework will find the main entry point and load the application.


here are my screen shots of my fist application written for smart phone





Thursday, May 17, 2007



Microsoft® Visual Studio® code name “Orcas” delivers on Microsoft’s vision of smart client applications by enabling developers to rapidly create connected applications that deliver the highest quality rich user experiences. With Visual Studio code name “Orcas”, organizations will find it easier than ever before to capture and analyze information so that they can make effective business decisions. Visual Studio code name “Orcas” enables any size organization to rapidly create more secure, manageable & reliable applications that take advantage of Windows Vista and the 2007 Office system.

more

Wednesday, May 16, 2007

Auto Numbering in Grid view

this article shows how to do auto numbering in grid view

in some cases we need to provide numbering of rows

in the folowing example i have connected a datatable with grid view

here is the htmnl code of grid view



<asp:GridView ID="GridView1" runat="server" AllowPaging="True" OnRowDataBound="GridView1_RowDataBound" AutoGenerateColumns="False" ShowFooter="True" PageSize="5" OnPageIndexChanging="GridView1_PageIndexChanging">
<Columns>
<asp:TemplateField HeaderText="No" Visible="False"></asp:TemplateField>
<asp:BoundField DataField="name" HeaderText="Name" />
<asp:BoundField DataField="gender" HeaderText="Gender" />

<asp:BoundField DataField="origin" HeaderText="Origin" />
</Columns>
</asp:GridView>




protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DataRowView drv = (DataRowView) e.Row.DataItem;

if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
if (drv["gender"].ToString() == "M")
{
e.Row.Cells[3].Text = "Male";
}
else
{
e.Row.Cells[3].Text = "Female";

}

}
}


e.Row.Cells[0].Text = Convert.ToString(e.Row.DataItemIndex + 1);
is the line giving auto numbering

also the datatable has a field called gender which contains the value M/F

if it is M cell will contain Male
if it is F cell will contain Female

Thursday, May 10, 2007

Page Lifecycle of Asp.net 2.0

One of the most important things to understand when building Web applications with ASP.NET is the sequence of events during the processing of a page.

Method names and the events they bind to in ASP.NET 2.0

Method Name------------Event

Page_PreInit-----------Page.PreInit
Page_Init--------------Control.Init
Page_InitComplete------Page.InitComplete
Page_PreLoad-----------Page.PreLoad
Page_Load--------------Control.Load
Page_LoadComplete------Page.LoadComplete
Page_PreRender---------Control.PreRender
Page_DataBind----------Control.DataBinding
Page_PreRenderComplete-Page.PreRenderComplete
Page_SaveStateComplete-Page.SaveStateComplete
Page_Unload------------Control.Unload
Page_Error-------------TemplateControl.Error
Page_AbortTransaction--TemplateControl.AbortTransaction
OnTransactionAbort --TemplateControl.AbortTransaction
Page_CommitTransaction-TemplateControl.CommitTransaction
OnTransactionCommit----TemplateControl.CommitTransaction
LINQ

At the Microsoft Professional Developers Conference (PDC) 2005, Anders Hejlsberg and his team presented a new approach, Language-Integrated Query (LINQ), that unifies the way data can be retrieved in .NET. LINQ provides a uniform way to retrieve data from any object that implements the IEnumerable interface. With LINQ, arrays, collections, relational data, and XML are all potential data sources.

LINQ to Objects is an API that provides methods that represent a set of standard query operators (SQOs) to retrieve data from any object whose class implements the IEnumerable interface. These queries are performed against in-memory data.

LINQ to ADO.NET augments SQOs to work against relational data. It is composed of three parts (which appear at the bottom level of Figure 1): LINQ to SQL (formerly DLinq) is use to query relational databases such as Microsoft SQL Server.

LINQ to DataSet supports queries by using ADO.NET data sets and data tables. LINQ to Entities is a Microsoft ORM solution, allowing developers to use Entities (an ADO.NET 3.0 feature) to declaratively specify the structure of business objects and use LINQ to query them.

LINQ to XML (formerly XLinq) not only augments SQOs but also includes a host of XMLspecific features for XML document creation and queries.

Requirements

LINQ is a combination of extensions to .NET languages and class libraries that support them.

To use it, you'll need the following:

• LINQ, which is available from the LINQ Project website at
http://msdn.microsoft.com/data/ref/linq. I've used the May 2006 CTP for this book.
• NET 2.0 running on Windows 2000 (Service Pack 4), Windows Server 2003, Windows XP
Pro (Service Pack 2), or Windows Vista.
• To write C# programs using LINQ, you need either Visual Studio 2005 or Visual C#
2005

Express Edition.
• To use LINQ to ADO.NET, you need SQL Server 2005, SQL Server 2005 Express Edition,
or SQL Server 2000.
• If you want to use LINQ with .NET 3.0 (originally WinFX), you need the WinFX
Runtime

Resources

There's a lot of good material available about LINQ:
• The LINQ May 2006 CTP includes a complete set of documentation.
• The main LINQ Project site (http://msdn.microsoft.com/data/ref/linq) includes a
Forums section where thousands of developers discuss LINQ, ask for support, and
report bugs.
• At http://shop.ecompanystore.com/mseventdvd/MSD_Shop.asp you can order the DVD
that contains full sessions from PDC 2005, where LINQ was unveiled.
• On the Channel 9 site (http://channel9.msdn.com), Anders Hejlsberg and his team are
often interviewed about LINQ issues and development.
Beta 2.

Wednesday, May 09, 2007

Validating Drop Down List with RequiredFieldValidator

we can validate a drop down list with a required field validator

below is a dropdown with some sample data



<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Select</asp:ListItem>
<asp:ListItem>Newton</asp:ListItem>
<asp:ListItem>Davinci</asp:ListItem>
</asp:DropDownList>


and for the validator i have bound it to the drop down using the control to validate property


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1"
ErrorMessage="Please Select An item for the list" InitialValue="Select"></asp:RequiredFieldValidator>


after that we have to set the InitialValue property of the validator
i have set the value as select...the validator will not allow to select the default value ie "select"

also the InitialValue property is case sencitive we have to give the value correctly

Tuesday, April 24, 2007

Regular Expressions
the following codes in this article throws light to some of the commonly used regular expression..all are coded with c#,asp.net

How to Find a text and Replace with other text
string FindAndReplace(string text)
{
string str = text;
Regex rgx = new Regex( class="str">@"\bbuddha\b");
if (rgx.IsMatch(text))
{
str = rgx.Replace(str, "mybuddha");
}
return str;
}


Testing complexity of password using regular expression validator
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="RegularExpressionValidator" ValidationExpression="(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]).{7,15}"></asp:RegularExpressionValidator></div>


Splitting comma seperated files with a br tag
string SplitLine(string text)
{
string str = text;
Regex rgx = new Regex(@",\s*");
if (rgx.IsMatch(text))
{
str = rgx.Replace(str, ",<br>" );
}
return str;
}

SplitLine("Microsoft,Linux,Oracle");
will return
Microsoft,
Linux,
Oracle




Extracting Query Strings from URLs
Regex rgx= new Regex( "\\?(?<query>[^<>#\"]+)" );




Extracting Filenames from Paths
Regex rgx = new Regex( ?
"(?<path>(\\\\(?<file>[^\\\\/:*?\"<>|.][^\\\\/:*?\"<>|]*))+)" );




Extracting Extensions from Filenames
Regex rgx = new Regex( ?
"\\\\[^\\\\/:*?\"<>|]+\\.(?<ext>[^.\\\\/:*?\"<>|]+)" );




Formatting U.S. Dates
Regex rgx = new Regex( @"^(\d{1,2})[-\/.]?(\d{1,2})[-\/.]?((?:\d{2}|\d{4}))$" );




Formating Dates
string FormatDates(string text)
{
string str = text;
Regex rgx = new Regex(@"(?:(?<=^)|(?<=[^\d]))(\d)(?=[^\d])");

if (rgx.IsMatch(text))
{
str = rgx.Replace(str, @"0$1");
}

return str;

}
1/1/2007 will become 01/01/2007




Validating Credit Card Numbers
<asp:RegularExpressionValidator Id="revInput" RunAt="server"
ControlToValidate="txtInput"
ErrorMessage="Please enter a valid value"
ValidationExpression="^(\d{4}-){3}|(\d{4} ){3}\d{4}|\d{15,16}|?
\d{4} \d{2} \d{4} \d{5}|\d{4}-\d{2}-\d{4}-\d{5}$"
>
</asp:RegularExpressionValidator>




Validating Dates in MM/DD/YYYY Format
<asp:RegularExpressionValidator Id="revInput" RunAt="server"
ControlToValidate="txtInput"
ErrorMessage="Please enter a valid value"
ValidationExpression="^(0?2/(0?[1-9]|[12][0-9])|
(0?[469]|11)/(0?[1-9]|[12][0-9]|30)|
(0?[13578]|1[02])/(0?[1-9]|[12][0-9]|3[01]))/\d{4}$"
>
</asp:RegularExpressionValidator>