calendar problem

G

Guest

Hi there,
I have a problem with a calendar control. I put the following function in
the SelectionChanged event

public void DatePick(object sender, System.EventArgs e)
{
TxtDate.Text = Calendar1.SelectedDate.ToShortDateString();
Calendar1.Visible = false;
}

I open and close the calendar with this function:

public void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventArgs e)
{
Calendar1.Visible = (Calendar1.Visible == false) ? (true) : (false);
}

The problem is if the user selects the same day which has been previously
selcted the Calendar will not disappear, because the selection has not
changed. How could I make the Calendar disappear when the user selects the
same day? Putting code in the Page.IsPostBack event does not do the trick..

Any sugestions are welcome. Thanks a lot

Chris
 
T

twostepted

One way would be to provide a Calendar1_OnClick event override and hook
up the Calendar's Click event to fire this method.

public void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventA­rgs e)
{
if(Calendar1.SelectedDate.ToShort­DateString() ==
DateTime.Today.ToShortDateString())
{
// save date?
}
Calendar1.Visible =
(Calendar1.Visible == false) ? (true) : (false);
}
 
G

Guest

Unfortunately this does not do the trick. What I menat is that I can not make
the calendar "invisible" when someone clicks on the same day which has been
selected before.

Chris
 
T

twostepted

Chris,

Sorry, are you sure that you can't use it? Does the calendar not
provide a Click delegate which you can hook an Calendar1_OnClick
delegate to? I had a typo in my last post, should have been

public void Calendar1_OnClick(object sender,
System.Web.UI.ImageClickEventA­­rgs e)

rather than

public void ImageButton1_Click(object sender,
System.Web.UI.ImageClickEventA­­rgs e)

If the calendar provides this method, you can do a
Calendar1.Click += new EventHandler(Calendar1_OnClick);

Are you familiar with this type of code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top