Jump to content

Displaying Monthly Calender Using Asp


Jhone

Recommended Posts

Well, I've done exactly that with PHP, but I havent studied into ASP. Here'es my php code:

<?phpheader ("location: page.php?one=set");?><html><head><title>Calender</title></head><body><?phpif (isset($_GET['one']))echo "<table id='TO' cellspacing='1' cellpadding='2'><tbody><tr><td><center>January</center></td></tr><tr><td>Sun</td><td>Mon</td><td>Tues</td><td>Weds</td><td>Thurs</td><td>Fri</td><td></tr><tr><td>1</td><td>2</td><td>

etc ...Then when you finish all the days in rows and datas, do this:

<form><input type='submit' id='two' value='Next'></form>";if (isset($_GET['two']))echo "

Then of course the same thing for Feb.

Link to comment
Share on other sites

Well, I've done exactly that with PHP, but I havent studied into ASP. Here'es my php code:
<?phpheader ("location: page.php?one=set");?><html><head><title>Calender</title></head><body><?phpif (isset($_GET['one']))echo "<table id='TO' cellspacing='1' cellpadding='2'><tbody><tr><td><center>January</center></td></tr><tr><td>Sun</td><td>Mon</td><td>Tues</td><td>Weds</td><td>Thurs</td><td>Fri</td><td></tr><tr><td>1</td><td>2</td><td>

etc ...Then when you finish all the days in rows and datas, do this:

<form><input type='submit' id='two' value='Next'></form>";if (isset($_GET['two']))echo "

Then of course the same thing for Feb.

Link to comment
Share on other sites

Here an ASP version I have written in Javascript. This will output the months between a start and end date. It doesn't have links for back or next, but it should give you an idea about how to dynamically draw a month and week. The extra date functions were because of some inconsistencies in dates from different databases. You can see on the bottom that echo is just an alias for Response.Write.

var dateObj = new Date();var day_size = 50; // pixelssDate = get_dateinfo(get_dateval(1, 1, 2009);eDate = get_dateinfo(get_dateval(12, 31, 2009);dateObj = get_dateinfo(sDate["value"]);cur_month = dateObj["mon"]-1;cur_year = dateObj["year"];done = false;left = true;var today = new Date();today = get_dateinfo(get_dateval(today.getMonth()+1, today.getDate(), today.getFullYear()));echo("<table border=0 align=\"center\" cellspacing=0 cellpadding=3>\n");while (!done){  if (dateObj["mon"] != cur_month)  {	//set up new month	if (left)	  echo("<tr>");	echo("<td valign=\"top\">");	echo("<table cellpadding=1 cellspacing=0 width=100% style=\"border-width: 3px; border-color: #000000; border-style: solid;\">");	echo("<tr><td align=\"center\" colspan=7 class=\"calendar_month\">" + write_monthname(dateObj["mon"]) + " " + dateObj["year"] + "</td></tr>");	echo("<tr class=\"calendar_content\"><td align=\"center\">Sun</td><td align=\"center\">Mon</td><td align=\"center\">Tue</td><td align=\"center\">Wed</td><td align=\"center\">Thu</td><td align=\"center\">Fri</td><td align=\"center\">Sat</td></tr>\n");  }  cur_month = dateObj["mon"];  cur_year = dateObj["year"];  if (dateObj["day"] == 0)	echo("<tr height=" + day_size + ">");  if (dateObj["date"] == 1 && dateObj["day"] != 0)  {	//advance gray days (days in previous month)	echo("<tr height=" + day_size + ">");	for (j = 0; j < dateObj["day"]; j++)	  echo("<td width=" + day_size + " class=\"calendar_gray\"> </td>");  }  /////////////////////////////////////////////////////////////////////////////  // draw the day!  /////////////////////////////////////////////////////////////////////////////  if (today["date"] == dateObj["date"] && today["mon"] == dateObj["mon"] && today["year"] == dateObj["year"])	echo ("<td width=" + day_size + " valign=\"top\" class=\"bg_today\">"); // today  else  {	if (dateObj["day"] == 0 || dateObj["day"] == 6)	  echo("<td width=" + day_size + " valign=\"top\" class=\"calendar_wkend\">"); // weekend	else	{	  echo("<td width=" + day_size + " valign=\"top\" class=\"calendar_day\">"); // week day	}  }  echo(dateObj["date"]); // write date  echo("</td>\n");  //end the day  /////////////////////////////////////////////////////////////////////////////  /////////////////////////////////////////////////////////////////////////////  if (dateObj["day"] == 6)	echo("</tr>");  //end the week  dateObj = get_dateinfo(dateObj["value"] + 1);  //advance a day  if (dateObj["mon"] != cur_month)  {	//end of month	if (dateObj["day"] != 0)	{	  for (j = dateObj["day"]; j <= 6; j++)		echo("<td width=" + day_size + " class=\"calendar_gray\"> </td>");	}	echo("</tr></table></td>");	if (!left)	  echo("</tr>");	left = !left;  }  if (dateObj["mon"] == eDate["mon"] && dateObj["year"] == eDate["year"])	done = true;}echo("</table>");function echo (str){  Response.Write(str);}function write_monthname (month){  switch (month)  {	case 1:	  return "January";	  break;	case 2:	  return "February";	  break;	case 3:	  return "March";	  break;	case 4:	  return "April";	  break;	case 5:	  return "May";	  break;	case 6:	  return "June";	  break;	case 7:	  return "July";	  break;	case 8:	  return "August";	  break;	case 9:	  return "September";	  break;	case 10:	  return "October";	  break;	case 11:	  return "November";	  break;	case 12:	  return "December";	  break;  }}/////////////////////////////////////////////////////////////////////////////////  get_dateval///////////////////////////////////////////////////////////////////////////////function get_dateval (mon, day, year){  var newDate = new Date(year, mon-1, day, 0, 0, 0, 0);  var oldDate = new Date(1980, 0, 1, 0, 0, 0, 0);  var retval = newDate.valueOf() - oldDate.valueOf();  retval = retval / 86400000;  return retval;}////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  get_dateinfo///////////////////////////////////////////////////////////////////////////////function get_dateinfo (val){  var dateObj = new Date(1980, 0, 1, 0, 0, 0, 0);			   //base of 1980  var newDate = new Date(dateObj.valueOf() + (86400000 * val)); //add days  var retval = new Array();  retval["mon"] = newDate.getMonth() + 1;  retval["date"] = newDate.getDate();  retval["year"] = newDate.getFullYear();  retval["value"] = val;  retval["day"] = newDate.getDay();  switch (retval["mon"])  {	case 1:	case 2:	case 3:	  retval["quarter"] = 1;	  break;	case 4:	case 5:	case 6:	  retval["quarter"] = 2;	  break;	case 7:	case 8:	case 9:	  retval["quarter"] = 3;	  break;	case 10:	case 11:	case 12:	  retval["quarter"] = 4;	  break;  }  return retval;}///////////////////////////////////////////////////////////////////////////////

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...