Wednesday, June 21, 2006

Recommended Articles on Asp.net

Articles on Asp.net
->Asp.net page life cycle
http://msdn2.microsoft.com/en-us/library/ms178472.aspx
->Asp.net Web Server Control Event Model
http://msdn2.microsoft.com/en-us/library/y3bwdsh3.aspx
->Page and Application Context in ASP.NET Web Applications
http://msdn2.microsoft.com/en-us/library/swe97x0b.aspx
->View State Overview
http://msdn2.microsoft.com/en-us/library/ms178198.aspx
->Binding to Data Using a Data Source Control
http://msdn2.microsoft.com/en-us/library/ms228089.aspx
->ASP.NET State Management Overview
http://msdn2.microsoft.com/en-us/library/75x4ha6s.aspx
->Session State Overview
http://msdn2.microsoft.com/en-us/library/ms178581.aspx
->ASP.NET State Management Recommendations
http://msdn2.microsoft.com/en-us/library/z1hkazw7(VS.80).aspx

Happy Programming,
Kamlesh

Wednesday, October 26, 2005

How to find out first saturday of year?

Solution 1.

DateTime x = GetFirstDayOccurrence(2005,DayOfWeek.Saturday );
public DateTime GetFirstDayOccurrence(int Year, DayOfWeek SearchDay)
{
int Day = 1;
for (int e=1; e<=7; e++)
{
if ( DateTime.Parse(e + "/jan/" + Year).DayOfWeek == SearchDay )
{
Day = e;
break;
}
}
return DateTime.Parse(Day + "/jan/" + Year);
}



Solution 2.

int year = 2005;
int days = DateTime.DaysInMonth(year, 1);
for (int i=1; i<=days; i++)
{
DateTime dt = DateTime.Parse(string.Format("{0}-01-{1}", year, i.ToString().PadLeft(2, '0')));
if (dt.DayOfWeek == DayOfWeek.Saturday)
{
Console.WriteLine("first saturday of {0} is {1}", year, dt.ToString("yyyy-MMM-dd"));
break;
}
}

Happy Programming,
Kamlesh

Monday, October 24, 2005

Create new directory programatically in c#

Here is the little code snippet which creates directory under inetpub/wwwroot folder
Code snippet:
foreach (string s in Directory.GetLogicalDrives())
{
//Find the drive I'm looking for
string sPath="" ;
sPath=s + "inetpub/wwwroot/";
if (Directory.Exists(sPath ))
{
DirectoryInfo r = new DirectoryInfo(sPath);
r.CreateSubdirectory("MyFolder");
}
}

plz feel free to deconstruct this code.

Happy Programming!!!

Regards,
Kamlesh