popup calendar

dhj

Regular
Joined
Sep 18, 2003
Messages
82
Location
Sri Lanka
hi again
i'm very new to .net and C#
i want to add a popup calendar in my web application. it has to be appeared when i click on a textbox (txtDate) and afterwards selected date of the pop up calendar should write in the txtDate textbox. i don't know how to write coding for a popup calendar and for the above function. i'm using .net and C# for my web application.

plus can i show a date in a textbox. is there any special method to do this. cos in one of my C# function i used following code

txtDate.text=Calendar1.SelectedDate;

where txtDate is a text box and the Calendar1 is a Calendar it's giving me an error saying "cannot convert datetime in to string"

and i want to format the date as dd/mmm/yy too

thank you very much in advance
 
About the date issue. To convert anything to a string in c# just put +"" after it or .ToString(); I use +"" just because I think it is faster and less characters.

These are examples:
DateTime.Now.DayOfYear+"";
DateTime.Now.Date.Month+"";
Just be creative.

Adding a popup calendar; just use MouseDown for the textbox and .Show it then. All the rest of the time .Hide it.
 
thank u
converting date in to string is working perfectly thank u again

but the pop up calencar thing didn't work

thx
 
yeah
i have added a text box and a calendar and i have set the visible property of calendar to false

<asp:calendar id=Calendar1 runat="server" Visible="False"></asp:calendar>

and in the textbox i used the following code

<INPUT id=txtDateOfBirth onmousedown="txtDateOfBirth_Click"
type=text runat="server">

and in my code behind page(C#) i wrote the following code

public void txtDateOFBirth_Click(object sender, System.EventArgs e)
{
Calendar1.Visible=true;
}


it didn't work for onmousedown so i used onclick method but it's still not working

thank you
 
it is not working for me at all i'll send u simple page having that controllers if u can pls check that
i've attached those two files

thank u very much
 

Attachments

You forgot to hook up the Click event in InitializeComponent().
this.Click += new MouseEventHandler(this.txt_Click);
 
Back
Top