locked
Calendar Selected Date RRS feed

  • Question

  • Hi i am currently coding a simple website in c#. I have a calendar and a textbox and i would like the textbox to display a certain message if a certain date is selected. I'm still a beginner and im stuck at

    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
    if Calendar1.SelectedDate = ???
    TextBox1.Text = "on this date i will blablabla";
    }

    I'm just wondering if it is possible to have a certain text be printed out within the textbox when a date is selected however i'm stuck there. Any help would be appreciated.

    Tuesday, July 12, 2011 12:45 PM

Answers

  • Hello

    You problem only to give a condition there

    _____________________________________________________________

    if (Calendar1.SelectedDate.ToShortDateString()  != "")

            {

                TextBox1.Text = "You have selected this Date:"+Calendar1.SelectedDate.ToShortDateString();

            }

     

    ________________________________________

    Or as different way

    if (Calendar1.SelectedDate != null)

            {

                TextBox1.Text = "You have selected this Date:" + Calendar1.SelectedDate.ToShortDateString();

            }

    ______________________________________________________

    Thanks

    sankar


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Wednesday, July 13, 2011 7:46 AM
  • Hi Deaths_eclipsE ,

    Yes you can do it. Try this code. I used 7/12/2011 as the comparing date.

    if (Calendar1.SelectedDate.ToShortDateString().ToString() == "7/12/2011")
          TextBox1.Text = "on this date i will blablabla";
        else
          TextBox1.Text = "";
    


    CHEERS.

    -------------------------------------------------------------------------------------------------------------------

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    ------------------------------------------------------------------------------------------------------------------

    Tuesday, July 12, 2011 1:13 PM
  • Hi

    if(Calendar1.SelectedDate.ToShortDateString==???)

    {

    // do what you want

    }


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, July 12, 2011 3:27 PM

All replies

  • Hi Deaths_eclipsE ,

    Yes you can do it. Try this code. I used 7/12/2011 as the comparing date.

    if (Calendar1.SelectedDate.ToShortDateString().ToString() == "7/12/2011")
          TextBox1.Text = "on this date i will blablabla";
        else
          TextBox1.Text = "";
    


    CHEERS.

    -------------------------------------------------------------------------------------------------------------------

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    ------------------------------------------------------------------------------------------------------------------

    Tuesday, July 12, 2011 1:13 PM
  • Hi

    if(Calendar1.SelectedDate.ToShortDateString==???)

    {

    // do what you want

    }


    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".
    Tuesday, July 12, 2011 3:27 PM
  • Hello

    You problem only to give a condition there

    _____________________________________________________________

    if (Calendar1.SelectedDate.ToShortDateString()  != "")

            {

                TextBox1.Text = "You have selected this Date:"+Calendar1.SelectedDate.ToShortDateString();

            }

     

    ________________________________________

    Or as different way

    if (Calendar1.SelectedDate != null)

            {

                TextBox1.Text = "You have selected this Date:" + Calendar1.SelectedDate.ToShortDateString();

            }

    ______________________________________________________

    Thanks

    sankar


    Please mark the post answered your question as the answer, and mark other helpful posts as helpful, so they will appear differently to other users who are visiting your thread for the same problem.
    Wednesday, July 13, 2011 7:46 AM