owl

Sunday, December 20, 2009

How to rise button Click from page load

protected void Page_Load(object sender, EventArgs e)
{

Button1_Click(Button1,new EventArgs());
}


void Button1_Click(object sender, EventArgs e)
{

//your code

}

Friday, November 20, 2009

RegEx for allowing numeric value

Expression ^\d{0,2}(\.\d{1,2})?$

Description This regular expression validates that the data entered is a number with a maximum of two integers and two decimals and a minimum of one integer or one decimal.

Matches 99.99 | 99 | .99

Non-Matches 999.999 | 999 | .999

Wednesday, October 28, 2009

RegEx for Time in HH:MM AM/PM

if(txtTime.value.match("^(([0]?[1-9])|([1][0-2])):(([0-5][0-9])|([1-9])) [AP][M]$"))
{
alert("valid date");
}

Tuesday, October 27, 2009

Convert Date to DD/MM/YYYY format in VB.net

Dim enGB As System.Globalization.CultureInfo = New System.Globalization.CultureInfo("en-GB")

Dim dtDate as datetime

dtDate=Convert.ToDateTime(dpadmitdate.text, enGB)
---------------------------------------------------------------------------------------

To show date time from database in a different format(AM and PM

lbldate.Text = Convert.ToDateTime(dsResult.Tables(0).Rows(0)("CreatedDate").ToString()).ToString("dd-MMM yyyy hh:mm tt")

SQL DateName,DatePart

To get the Day of the given Date
---------------------------------
SELECT DATEPART(dw,GETDATE())
SELECT DATENAME(dw,GETDATE())

Monday, October 19, 2009

Regex for US phone number

if(txtbox.value.match("^(\\+?1[- ]?)?\\(?(\\d{3})\\)?[\\s-]?(\\d{3})[\\s-]?(\\d{4})$"))
{
alert('true');

}

Monday, October 5, 2009