Wednesday, July 7, 2010

Display Outage page in Asp.Net

App_offline.htm file used to display the error/notification message to the users when your site is under maintenance. if you keep this file your root directory no other files/requests will be processed.

Make a simple HTML file by writing "The application is under maintenance. Please try again later." and name it as App_offline.htm

Drop this file in your root directory of your web application folder.

After copying App_offline.htm file try to access your web application link and see the output.

How to find Browser type and version from code behind?

Copy paste below code in your code behind and see the out put!!!!!

string strBrowser= Request.Browser.Browser;//Display the browser type like IE, Mozilla etc.

string strBrowserVersion= Request.Browser.Version;//Display the browser version like IE 8.0,8.2 based on the release.

int intBrowserMajorVersion= Request.Browser.MajorVersion;//Display Browser major version like in IE 6,7,8

double dblBrowserMinorVersion= Request.Browser.MinorVersion;//Display Brwser Minor version like IE 1,2,3 based on the release.

Validate a user has entered a date in correct format such as mm/dd/yyyy format using JavaScript?

You can use below regular expression,

Just copy and paste this expression in your regular expression's ValidExpression property.

(?=\d)^(?:(?!(?:10\D(?:0?[5-9]|1[0-4])\D(?:1602))|(?:0?9\D(?:0?[3-9]|1[0-3])\D(?:1752)))((?:0?[13578]|1[02])|(?:0?[469]|11)(?!\/31)(?!-31)(?!\.31)|(?:0?2(?=.?(?:(?:29.(?!000[04]|(?:(?:1[^0-6]|[2468][^048]|[3579][^26])00))(?:(?:(?:\d\d)(?:[02468][048]|[13579][26])(?!\x20BC))|(?:00(?:42|3[0369]|2[147]|1[258]|09)\x20BC))))))|(?:0?2(?=.(?:(?:\d\D)|(?:[01]\d)|(?:2[0-8])))))([-.\/])(0?[1-9]|[12]\d|3[01])\2(?!0000)((?=(?:00(?:4[0-5]|[0-3]?\d)\x20BC)|(?:\d{4}(?!\x20BC)))\d{4}(?:\x20BC)?)(?:$|(?=\x20\d)\x20))?((?:(?:0?[1-9]|1[012])(?::[0-5]\d){0,2}(?:\x20[aApP][mM]))|(?:[01]\d|2[0-3])(?::[0-5]\d){1,2})?$