Wednesday, September 9, 2009

ASP.NET Ajax Calendar Extender and Validation ...

ASP.NET Ajax CalendarExtender and Validation ...


ASP.NET Ajax toolkit has a CalendarExtender control which is very cool as you can associate the CalendarExtender to a a TextBox and also to a Button/ImageButton so that you can popup the calendar.

Below is the code to get started with CalendarExtender:

ID="TextBox1"
runat="server"
width="300pt" />
ID="btnCalenderPopup"
Width="16" Height="16"
runat="server"
ImageUrl="~/images/calender.bmp"
CausesValidation="False" />
ID="CalendarExtender1"
runat="server"
TargetControlID="TextBox1"
PopupButtonID="btnCalenderPopup"
Format="dd/MM/yyyy" />

And here is the output:




Wait! What’s that grayed text in the textbox that says - Enter the Date of Birth (dd/mm/yyyy)

Certainly that’s not the part of CalendarExtender :) , but part of ASP.NET Ajax Toolkit 8) . We can use the TextBoxWatermarkExtender which can display watermarked (grayed) texts on controls. Below is the code for our CalendarExtender :

ID="WatermarkExtender1"
runat="server"
TargetControlID="TextBox1"
WatermarkCssClass="watermarked"
WatermarkText="Enter the Date of Birth (dd/mm/yyyy)" />

And below is the CSS style that’s used with this watermark extender :

.watermarked
{
color: #C0C0C0;
font-style: italic;
}

All looks good now and the user is happy the way Calendar pops up, choosing the date and also the fact that he can type in the date in the textbox in the desired format. Now comes the problem - Date Validation! - How are we going to validate the entered date? - I had to validate that the date entered is not more than today’s date.

There are two ways to do it :

1) Using Javascript (with our CalendarExtender)

2) Using RangeValidators for our textbox

Using Javascript:

The CalendarExtender has a property called OnClientDateSelectionChanged which can be set to a piece of javascript which can do the job for us. Below is the code:

ID="CalendarExtender1"
runat="server"
TargetControlID="TextBox1"
PopupButtonID="btnCalenderPopup"
OnClientDateSelectionChanged="checkMyDate"
Format="dd/MM/yyyy" />

and below is the javascript:



Using RangeValidator:

Since we use a TextBox control to display our date once we choose from the calendar or to manually input the date, RangeValidators can be used to check whether the date is within a given range (minimum & maximum). Below is the code for RangeValidator :

ID="RangeValidator1"
runat="server"
ControlToValidate="TextBox1"
ErrorMessage="*Please enter proper date"
Type="Date" Display="Dynamic" />

And in your page load event we can set our maximum and minimum date values :

RangeValidator1.MinimumValue
= new DateTime(1600, 01, 01).ToString("dd/MM/yyyy");
RangeValidator1.MaximumValue
= DateTime.Now.ToString("dd/MM/yyyy");

With these two methods you can easily validate the date. And yes, using both would sometimes lead you to race conditions where choosing a date from the calendar might be an invalid date and the RangeValidators would immediately come to the focus

Tuesday, September 8, 2009

Cricket Match Schedule 2010

2010 Cricket Match Schedule



















































England Cricket Schedule : Year 2010

Months

Versus

Matches

Fixtures & Result

January

England in South Africa

4 tests + 5 ODI + T20

Eng in SA 2010

February-March

England in Bangladesh

2 tests + 3 ODIs

Eng in Bdesh 2010

April

T20 WC in West Indies

Twenty20 World cup

World T20 2010

May

Bangladesh in England

2 Test + 3 ODI

Bdesh in Eng 2010

June

Australia in England

5 ODI Series

Aus in Eng 2010

July-August

West Indies in England

4 Test + 5 ODI

WI in Eng 2010

Nov-Dec

England in Australia

Ashes 2011

Ashes 2010
























































India Cricket Schedule : Year 2010

January

India in Bangladesh

2 Test + Triseries

India in Bdesh 2010

February-March

South Africa in India

3 Test + 5 ODI

SA in Ind 2010

April

Asia Cup

ODI Tournament

Asia Cup 2010

April

T20 WC in West Indies

Twenty20 World Cup

World T20 2010

May

India in Zimbabwe

3 ODI Series

Ind in Zim 2010

July

India in Sri Lanka

Triseries

Ind v NZ v SL

October

Australia in India

7 ODI Series

Aus in Ind 2010

November

New Zealand in India

3 Test + 5 ODI

NZ in Ind 2010






























































Australia Cricket Schedule : Year 2010

January

Pakistan in Australia

3 Test + 5 ODI + T20

Pak in Aus 2010

February

West Indies in Australia

5 ODI + T20

WI in Aus 2010

March-April

Australia in New Zealand

3 Test + 5 ODI + 2 T20s

Aus in NZ 2010

April

T20 World Cup in WI

Twenty20 World Cup

World T20 2010

June

Australia in England

5 ODI Series

Aus in Eng 2010

July

Bangladesh in Australia

2 Tests

Bdesh in Aus 2010

September

Australia in Pakistan

3 Tests

Aus in Pak 2010

October

Australia in India

7 ODI series

Aus in Ind 2010

November

England in Australia

5 Test Series

Ashes 2010-11












































Pakistan Cricket Schedule : Year 2010

January

Pakistan in Australia

3 Test + 5 ODI + T20

Pak in Aus 2010

April

Asia Cup

ODI Tournament

Asia Cup 2010

April

T20 World cup in West Indies

Twenty20 World Cup

World T20 2010

August

Bangladesh in Pakistan

2 Test + 3 ODI

Bdesh in Pak 2010

September

Australia in Pakistan

3 Test Series

Aus in Pak 2010

Oct-Nov

South Africa in Pakistan

3 Test + 5 ODI

SA in Pak 2010












































New Zealand Cricket Schedule : Year 2010

February

Bangladesh in New Zealand

1 Test, 3 ODI, 2 T20

Bdesh in NZ 2010

March-April

Australia in New Zealand

Test + ODI + T20

Aus in NZ 2010

April

T20 World cup in West Indies

Twenty20 World Cup

WC T20 2010

July

New Zealand in Sri Lanka

Triseries

Ind v NZ v SL

October

New Zealand in Bangladesh

2 Test + 3 ODI

NZ in Bdesh 2010

November

New Zealand in India

3 Test + 5 ODI

NZ in Ind 2010






































Sri Lanka Cricket Schedule : Year 2010

January

Srilanka in Bangladesh

Triseries

Ind v SL v Bdesh

April

Asia Cup

ODI Tournament

Asia Cup 2010

April

T20 World cup in West Indies

Twenty20 World Cup

WC T20 2010

July

India & New Zealand in Sri Lanka

Tri Series

Ind v NZ v SL

Nov-Dec

West Indies in Sri Lanka

3 Test + 5 ODI

WI in SL 2010












































South Africa Cricket Schedule : Year 2010

January

England in South Africa

4 Test + 5 ODI

Eng in SA 2010

February-March

South Africa in India

3 Test + 5 ODI

SA in Ind 2010

April

T20 World cup in WI

Twenty20 World Cup

WC T20 2010

May-June

South Africa in West Indies

4 Test + 5 ODI

SA in WI 2010

September

Zimbabwe in South Africa

ODI Series

Zim in SA 2010

Oct-Nov

South Africa in Pakistan

3 Test + 5 ODI

SA in Pak 2010












































West Indies Cricket Schedule : Year 2010

February

West Indies in Australia

5 ODI + T20

WI in Aus 2010

March

Zimbabwe in West Indies

ODI Series

Zim in WI 2010

April

T20 World cup in West Indies

Twenty20 World Cup

WC T20 2010

May-June

South Africa in West Indies

4 Test + 5 ODI

SA in WI 2010

July - August

West Indies tour of England

4 Test + 5 ODI

WI in Eng 2010

Nov-Dec

West Indies in Sri Lanka

3 Test + 5 ODI

WI in SL 2010




































































Bangladesh Cricket Schedule : Year 2010

January

SL & Ind in Bdesh

ODI Triseries

Ind v SL v Bdesh

January

India in Bangladesh

2 Tests

Ind in Bdesh 2010

February

Bangladesh tour of New Zealand

Test + ODI + T20

Bdesh in NZ 2010

March

England in Bdesh

Test + ODI

Eng in Bdesh 2010

April

Asia Cup

ODI Tournament

Asia cup 2010

April

T20 World cup in West Indies

Twenty20 World cup

World T20 2010

May

Bangladesh in England

2 Test + 3 ODI

Bdesh in Eng 2010

July

Bangladesh in Australia

2 Tests

Bdesh in Aus 2010

August

Bangladesh in Pakistan

2 Test + 3 ODI

Bdesh in Pak 2010

October

New Zealand in Bangladesh

2 Test + 3 ODI

NZ in Bdesh 2010