I have the below code but if there is some code in Ajax Javascript I will use it.
I feel like I am inventing the wheel.
I have to make sure that all these are c# and return the appropriate value.
I appreciate any help.
Expand|Select|Wrap|Line Numbers
- public string Populate_MonthList()
- {
- drpCalMonth.Items.Add("January");
- drpCalMonth.Items.Add("February");
- drpCalMonth.Items.Add("March");
- drpCalMonth.Items.Add("April");
- drpCalMonth.Items.Add("May");
- drpCalMonth.Items.Add("June");
- drpCalMonth.Items.Add("July");
- drpCalMonth.Items.Add("August");
- drpCalMonth.Items.Add("September");
- drpCalMonth.Items.Add("October");
- drpCalMonth.Items.Add("November");
- drpCalMonth.Items.Add("December");
- string strMonth;
- strMonth = DateTime.Now.ToString("MMMM");
- drpCalMonth.Items.FindByValue(strMonth).Selected = true;
- return (strMonth);
- }
- public int DaysInMonth(string strMonth, string strYear)
- {
- string strDay;
- // Get the current date to get the Year
- DateTime d = new DateTime();
- // Here Year is got from current date.
- var dd = new Date(strYear, strMonth, 0);
- // drpCalDay =
- // return dd.getDate();
- }
- // Avoid Leap Year
- function textDate(value)
- {
- var sel = document.forms[0].date;
- // Clear the select
- sel.options.length = 0;
- // Get the no of days in that month
- var NoOfDays = DaysInMonth(value);
- // Now for that no of dates you loop and build the select
- for(var i=1;i<=NoOfDays;i++)
- {
- // Create new option
- var option = new Option(i, "Value" + i);
- // Add the new option it to the select
- sel.options[i] = option;
- }
- }
- public string Populate_YearList()
- {
- int intYear;
- // Year list can be changed by changing the lower and upper
- // limits of the For statement
- for (intYear = DateTime.Now.Year - 18; intYear >= DateTime.Now.Year - 99; intYear--)
- {
- drpCalYear.Items.Add(intYear.ToString());
- }
- string strYear;
- strYear = DateTime.Now.ToString("yyyy");
- drpCalYear.Items.FindByValue(strYear).Selected = true;
- return (strYear);
- }