473,491 Members | 3,350 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Calendar onselectionchanged problem

I'm having problem with the onselectionchanged event. I won't fire.
Nothing happens when I select a day. That means, the page is posted
back, but the test-string is not written. My Page_Load function is
empty and the calendar renders just fine. Here's my code:
usercalendar.SelectionChanged += new
EventHandler(this.Calendar_selectday);
PlaceHolder1.Controls.Add(usercalendar);
public void Calendar_selectday(object sender, System.EventArgs
e)
{
Response.Write("Test");
}
Nov 18 '05 #1
6 4446

Hi Trond,

Do you have AutoPostBack = true on your calendar control?

Ethem

"Trond" wrote:
I'm having problem with the onselectionchanged event. I won't fire.
Nothing happens when I select a day. That means, the page is posted
back, but the test-string is not written. My Page_Load function is
empty and the calendar renders just fine. Here's my code:
usercalendar.SelectionChanged += new
EventHandler(this.Calendar_selectday);
PlaceHolder1.Controls.Add(usercalendar);
public void Calendar_selectday(object sender, System.EventArgs
e)
{
Response.Write("Test");
}

Nov 18 '05 #2
Thanks for your reply Ethem. But you can't set autopostback true/false
on calendarobjects, can you?
Anyway, the page gets postbacked when selecting a date, but the event
and hence my eventhandler function doesn't run.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3
Just for kicks, try adding a <div id='msg/> to your aspx page and in your
Calendar_selectday, set msg="Test";
does that work?

--
Girish Bharadwaj
http://msmvps.com/gbvb
"Trond" <tr*************@hotmail.com> wrote in message
news:dc**************************@posting.google.c om...
I'm having problem with the onselectionchanged event. I won't fire.
Nothing happens when I select a day. That means, the page is posted
back, but the test-string is not written. My Page_Load function is
empty and the calendar renders just fine. Here's my code:
usercalendar.SelectionChanged += new
EventHandler(this.Calendar_selectday);
PlaceHolder1.Controls.Add(usercalendar);
public void Calendar_selectday(object sender, System.EventArgs
e)
{
Response.Write("Test");
}

Nov 18 '05 #4
Thanks for the suggestion, but it didn't work. It seems like it never
hits the Calendar_selectday-function...

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5

Sorry, maybe I'm getting you wrong. Are you creating the calendar on runtime
and adding it to the placeholder? Problem can be that you don't create the
calendar on each postback and add the event to it. In this case, the event
binding will get lost. Try this;

protected PlaceHolder plHolder;
protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
protected Calendar cal;
private void Page_Load(object sender, System.EventArgs e)
{
cal = new Calendar();
cal.SelectionChanged +=new EventHandler(cal_SelectionChanged);
plHolder.Controls.Add(cal);
}
private void cal_SelectionChanged(object sender, EventArgs e)
{
Response.Output.Write(cal.SelectedDate.ToString()) ;
}

I tested and it works.

Hope this works,

Ethem
"Trond Wahlstrom" wrote:
Thanks for your reply Ethem. But you can't set autopostback true/false
on calendarobjects, can you?
Anyway, the page gets postbacked when selecting a date, but the event
and hence my eventhandler function doesn't run.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #6
Thanks again for the replies!

I sorted it out. The problem was that my binding of the
eventhandler(selectionchanged) was done to late in the page cycle. I
moved it into the Page_Load function and then it worked!

Thanks again!

...Trond

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1716
by: maxrawson | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
2
3394
by: Caesar Augustus | last post by:
First, let me start by saying my asp.net experience is still in it's infancy so please bare with me as I try to explain my situation. I have created a single page that with the use of many...
0
1470
by: GFro | last post by:
I have a calendar page that returns a date to a textbox on the parent page. It is returning the wrong format on the deployment server. On the development server the calendar returns to textbox in...
1
313
by: AllanD | last post by:
Hello everyone, I seem to be having a problem with getting the Calendar control that comes with Visual Studio to trap for the OnSelectionChanged event. When I click on a date in the calendar a...
1
1160
by: P K | last post by:
I have around 20 calendar controls on my screen besides 20 textboxes. The functionality of each control is the same, they take in a parameter for the textbox name and open a calendar in a popup....
0
1684
by: R.A.M. | last post by:
Hello, I need to implement popup calendar in ASP.NET application. I created a button opening popup calendar on 'master' page: <asp:Button ID="Calendar" runat="server" Text=Calendar"...
1
2721
by: R.A.M. | last post by:
Hello, I need to implement popup calendar in ASP.NET application. I created a button opening popup calendar on 'master' page: <asp:Button ID="Calendar" runat="server" Text=Calendar"...
3
3110
by: brianwolters | last post by:
Hello, I have a calendar and a textbox right below it on my webpage. I need help with creating some code to display information about the date the user clicked in the text box below it. For...
1
2820
by: phpmel | last post by:
Hi guys, I have an asp calendar control, text box, calendar icon, eraser icon all within an update panel. The calendar works fine, postbacks are handled without the flickering of the screen etc....
0
6980
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6862
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7364
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4886
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4579
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3087
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1397
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
282
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.