mat cupryk

mat cupryk

  • NA
  • 1
  • 0

need to pass two variables to a cascading function in ajax .net

Aug 1 2008 10:11 PM
I need to populate the cddDay where it takes two parameters from the other cascading drop downs
GetDayList ==> how should i modify the below code for this to work.

 <ajaxToolkit:CascadingDropDown ID="cddMonth" runat="server" Category="Month"
                TargetControlId="ddlMonth"
                LoadingText="[Loading Months...]"
                ServicePath="../LocationService.asmx"
                ServiceMethod="GetMonthList" Enabled="True" />
            <ajaxToolkit:CascadingDropDown ID="cddYear" runat="server" Category="Year"
                TargetControlId="ddlYear"
                LoadingText="[Loading Year...]"
                ServicePath="../LocationService.asmx"
                ServiceMethod="GetYearList" Enabled="True" />
            <ajaxToolkit:CascadingDropDown ID="cddDay" runat="server" Category="Day"
                TargetControlId="ddlDay"
                LoadingText="[Loading Year...]"
                ServicePath="../LocationService.asmx"
                ServiceMethod="GetDayList" Enabled="True" />
        </td>
        <td align="left" bordercolor="#f6cccc" height="35" style="width: 60%">
          <asp:DropDownList style="position: static" Font-Size="Smaller" Font-Bold="true" id="ddlMonth" Runat="Server"></asp:DropDownList>&nbsp;
          <asp:DropDownList style="position: static" Font-Size="Smaller" Font-Bold="true" id="ddlDay" Runat="Server"></asp:DropDownList>&nbsp;
          <asp:DropDownList style="position: static" Font-Size="Smaller" Font-Bold="true" id="ddlYear" Runat="Server"></asp:DropDownList>&nbsp;

  [WebMethod(Description = "Populate a year list.")]
    [System.Web.Script.Services.ScriptMethod]
    public AjaxControlToolkit.CascadingDropDownNameValue[] GetYearList(string knownCategoryValues, string category)
    {
        List<CascadingDropDownNameValue> yearList = new List<CascadingDropDownNameValue>();

        // Year list can be changed by changing the lower and upper
        // limits of the For statement
        int i = 1;
        for (int intYear = DateTime.Now.Year - 18; intYear >= DateTime.Now.Year - 99; intYear--)
        {
            yearList.Add(new CascadingDropDownNameValue(intYear.ToString(), (i++).ToString()));
        }
        return yearList.ToArray();
    }
    ///////////////////////////////////////////////////////////////////////////////////////

    [WebMethod(Description = "Populate a month list.")]
    [System.Web.Script.Services.ScriptMethod]
    public AjaxControlToolkit.CascadingDropDownNameValue[] GetMonthList(string knownCategoryValues, string category)
    {
        List<CascadingDropDownNameValue> monthList = new List<CascadingDropDownNameValue>();
   
       
        monthList.Add(new CascadingDropDownNameValue("January", "1"));
        monthList.Add(new CascadingDropDownNameValue("February", "2"));
        monthList.Add(new CascadingDropDownNameValue("March", "3"));
        monthList.Add(new CascadingDropDownNameValue("April", "4"));
        monthList.Add(new CascadingDropDownNameValue("May", "5"));
        monthList.Add(new CascadingDropDownNameValue("June", "6"));
        monthList.Add(new CascadingDropDownNameValue("July", "7"));
        monthList.Add(new CascadingDropDownNameValue("August", "8"));
        monthList.Add(new CascadingDropDownNameValue("September", "9"));
        monthList.Add(new CascadingDropDownNameValue("October", "10"));
        monthList.Add(new CascadingDropDownNameValue("November", "11"));
        monthList.Add(new CascadingDropDownNameValue("December", "12"));

        return monthList.ToArray();
    }
    ///////////////////////////////////////////////////////////////////////////////////////


    [WebMethod(Description = "Populate a days list for a specific month and year.")]
    [System.Web.Script.Services.ScriptMethod]
    public AjaxControlToolkit.CascadingDropDownNameValue[] GetDayList(string knownCategoryValues, string category, int year, int month)
    {
        List<CascadingDropDownNameValue> dayList = new List<CascadingDropDownNameValue>();

        int NumberOfDays = DateTime.DaysInMonth(year, month);

        for (int day = 1; day <= NumberOfDays; day++)
        {
            dayList.Add(new CascadingDropDownNameValue(day.ToString(), day.ToString()));
        }

        return dayList.ToArray();
    }
    /////////////////////////////////////////////////////////////////////////////////////////