Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a two rad date picker in my leave apply form with IDs rdpdatefrom and rdpdateto.
i have also used one textbox for no. of days. in this,when user enter no of days and select date from in rdpdatefrom,rdpdateto automatically fill according to no. of days and date enter in rdpdatefrom.but problem is,when user select date from (rdpdatefrom) and the selected day of date is saturday and user enter 2 days in textbox then according to datefrom and no of days enter in textbox,dateto is set to an sunday,i want dateto is set to monday.so finally i want that if user apply leave and if saturday,sunday,monday comes in sequence,so the datefrom is skip sunday.
for example-if user apply leave for two days and datefrom day of date is saturday,so dateto appears on monday.
my code is shown below:

C#
protected void rdpDateFrom_SelectedDateChanged(object sender, Telerik.WebControls.SelectedDateChangedEventArgs e)
  {
      if (txtnoOfday.Text == "")
      {
          lblDateMsg.Text = "Enter No. of Leave Days";
          lblDateMsg.Visible = true;

          rdpDateUpto.SelectedDate = null;
          rdpDateUpto.Enabled = false;
      }
      else
      {
          rdpDateUpto.Enabled = true;
          lblDateMsg.Visible = false;
          //rdpDateUpto.MinDate = Convert.ToDateTime(rdpDateFrom.SelectedDate);

        //  rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text)-1));
          rdpDateUpto.MinDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
         rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.SelectedDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
      }
  }



C#
protected void txtnoOfday_TextChanged(object sender, EventArgs e)
  {

      if (rdpDateFrom.SelectedDate ==null)
      {
          rdpDateUpto.SelectedDate = null;
      }
      else if (txtnoOfday.Text =="")
      {
          rdpDateFrom.SelectedDate = null;
          rdpDateUpto.SelectedDate = null;
      }
      else
      {
          rdpDateUpto.Enabled = true;
          lblDateMsg.Visible = false;
         // rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text)-1));
          rdpDateUpto.MinDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.MaxDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
          rdpDateUpto.SelectedDate = rdpDateFrom.SelectedDate.Value.AddDays((Convert.ToInt16(txtnoOfday.Text) - 1));
      }
  }
Posted

1 solution

You should check if
C#
datefrom.DayOfWeek = DayOfWeek.Saturday

and then do, what is necessary to be done (calculate new dateto or something like this).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900