locked
ASP.NET Calender selected not getting clear RRS feed

  • Question

  • User1259588416 posted

    Hi Guys,

    I Have one asp.nt calender , one label , one button .On selecting date from calender and then pressing button i am saving data in database.

    Button and label (To display message) have been kept inside same update panel. But when i click button and after saving task calender selected date is not

    cleared. Also it not get cleared when i do page refresh .But if i place calender inside update panel it will get cleared.

    How i can clear the selected date of calender?

    Please suggest 

    Monday, September 19, 2016 7:02 PM

Answers

  • User1724605321 posted

    Hi kaushiklotus,

    when you click the button, only controls that are inside the update panel will be updated.  The calendar control is outside the updatepanel.  So the easiest/quickest solution is to put the calendar inside the update panel as well. Another solution is to put that calendar in separate UpdatePanel and call .Update() whenever required.  Here is a demo :

    http://stackoverflow.com/a/2887120 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 23, 2016 2:40 AM

All replies

  • User1724605321 posted

    Hi kaushiklotus,

    Do you place calendar control in different update panel and Button and label in one update panel ? You could try to clear  SelectedDates of calendar control like :

            protected void Button1_Click(object sender, EventArgs e)
            {
                Calendar1.SelectedDates.Clear();
            
            }

    Best Regards,

    Nan Yu

    Tuesday, September 20, 2016 6:30 AM
  • User1259588416 posted

    Hi Nan,

    The above code is not working i had tried earlier.

    I have not put calender in update panel while button and label is in one update panel

    Friday, September 23, 2016 2:00 AM
  • User1724605321 posted

    Hi kaushiklotus,

    when you click the button, only controls that are inside the update panel will be updated.  The calendar control is outside the updatepanel.  So the easiest/quickest solution is to put the calendar inside the update panel as well. Another solution is to put that calendar in separate UpdatePanel and call .Update() whenever required.  Here is a demo :

    http://stackoverflow.com/a/2887120 

    Best Regards,

    Nan Yu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, September 23, 2016 2:40 AM