i have calendar placed on my form
i have one textbox n a button("Show date")
When the user enters date in the textbox say 29/07/2008 and click
on the show date button the calendar should show / reflect that date..
how to achieve this...i knw...it ll b simple but am not getting it...
i am also getting string to date conversion error n what not...
plz help me out...

protected void cmddate_Click(object sender, EventArgs e)
    {
        DateTime dt;
    // dt = txtdate.Text;
        DateTime.TryParse(txtdate.Text, out dt);
      //  DateTime.TryParse(dt, out dt); 
        Calendar1.VisibleDate = dt;

AM I USING CORRECT PROPERTY? PLZ SUGGEST
cya
Rohan

hi friend please use the following code...in button click

protected void Button1_Click(object sender, EventArgs e)
    {
        Calendar1.SelectedDate = Convert.ToDateTime(TextBox1.Text);
    }

tell me whether this solves or not.

For pure windows application use this. The above mentioned code is for webapplication in asp.net with c#.

private void button1_Click(object sender, EventArgs e)
        {
            monthCalendar1.SetDate(Convert.ToDateTime(textBox1.Text));
        
  
        }

am doing webapplication i use the following code :

Calendar1.SelectedDate = Convert.ToDateTime(txtdate.Text);

but i get following Error :
String was not recognized as a valid DateTime.
plz help me out.

For pure windows application use this. The above mentioned code is for webapplication in asp.net with c#.

private void button1_Click(object sender, EventArgs e)
        {
            monthCalendar1.SetDate(Convert.ToDateTime(textBox1.Text));
        
  
        }

Hi you need to enter the value in textbox as mm/dd/yy format
not dd/mm/yy format

okay??

i entered d date in text box as 07/22/08 (july 22 2008) but the calendar does not reflect that day....it still shows year 2009 date....
plz help meeeeeeeeeeeeee :(

cya
Rohan

Hi you need to enter the value in textbox as mm/dd/yy format
not dd/mm/yy format

okay??

hii ru there??
please use this line in the code

Calendar1.SelectedDate = Convert.ToDateTime(TextBox1.Text);
        Calendar1.VisibleDate = Convert.ToDateTime(TextBox1.Text);

let me know if u face pbm still...

Hurray.............i finally got it......................:) thanks a lotttttttttttttt buddyyyyyyyyyyyyyy.... :) :)


cya
Rohan

hii ru there??
please use this line in the code

Calendar1.SelectedDate = Convert.ToDateTime(TextBox1.Text);
        Calendar1.VisibleDate = Convert.ToDateTime(TextBox1.Text);

let me know if u face pbm still...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.