By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,312 Members | 1,900 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,312 IT Pros & Developers. It's quick & easy.

Calendar control not raising events in UserControl

P: n/a
I have a UserControl that contains a calendar control. The calendar is not
raising events (month navigation, date selections, etc.). I've checked that
the OnSelectionChanged event has a handler being registered. Is there
anything else obvious or otherwise that I've missed? Is there a problem
using it in a UserControl?

Thanks

Colin
Nov 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Colin,

Based on my research and experience, I would like to share the following
information with you.

Before the Page_Load event, asp.net loads in all the ViewState data, for
example, recreating your controls on web page. Then it matches up the
control that raises the postback with the actual control which was
regenerated from the ViewState. At this point, ASP.NET knows that this
particular control was fired and it adds the handler event to the list of
events that must be executed.

If the load phase was after the restore of the ViewState data, the event
will not fired as expected.

The ASP.NET page framework provides a technique called event bubbling that
allows a child control to propagate events up its containment hierarchy.
Event bubbling enables events to be raised from a more convenient location
in the controls hierarchy and allows event handlers to be attached to the
original control as well as to the control that exposes the bubbled event.

For more information, plesae check this article:

Bubbling an Event
http://msdn.microsoft.com/library/en...lingcommandeve
nt.asp

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #2

P: n/a
I've already checked the control tree using tracing and the UserControl that
is giving me trouble is being recreated with the same ID after postback, so
there should be no trouble matching up the event with the correct control.
The control is not dynamically created so there should be no trouble with it
being created too late in the process.

I'm attempting to handle the event within my User Control. Even if I add an
override for handling event bubbling, the OnEventBubble is never called. The
page does postback, it's just that the event never gets raised.

Just to be clear I have created a Web User Control, not a Custom Server
Control, although I may convert to a custom control since I have more
experience with those and have generally had better luck with them. I only
created a user control because I thought it would be quicker.

Colin

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:vg**************@cpmsftngxa06.phx.gbl...
Hi Colin,

Based on my research and experience, I would like to share the following
information with you.

Before the Page_Load event, asp.net loads in all the ViewState data, for
example, recreating your controls on web page. Then it matches up the
control that raises the postback with the actual control which was
regenerated from the ViewState. At this point, ASP.NET knows that this
particular control was fired and it adds the handler event to the list of
events that must be executed.

If the load phase was after the restore of the ViewState data, the event
will not fired as expected.

The ASP.NET page framework provides a technique called event bubbling that
allows a child control to propagate events up its containment hierarchy.
Event bubbling enables events to be raised from a more convenient location
in the controls hierarchy and allows event handlers to be attached to the
original control as well as to the control that exposes the bubbled event.

For more information, plesae check this article:

Bubbling an Event
http://msdn.microsoft.com/library/en...lingcommandeve nt.asp

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #3

P: n/a
Nevermind... I've figured out what the problem is and it has nothing to do
with the user control or the calendar. My page is accessed by a
server.transfer and uses url rewriting, so the postback isn't really
occuring.

Now that I know what the problem is I just need to figure out how to fix
it...

Colin

"Colin Young" <x@nospam.com> wrote in message
news:uN**************@TK2MSFTNGP09.phx.gbl...
I've already checked the control tree using tracing and the UserControl that is giving me trouble is being recreated with the same ID after postback, so there should be no trouble matching up the event with the correct control.
The control is not dynamically created so there should be no trouble with it being created too late in the process.

I'm attempting to handle the event within my User Control. Even if I add an override for handling event bubbling, the OnEventBubble is never called. The page does postback, it's just that the event never gets raised.

Just to be clear I have created a Web User Control, not a Custom Server
Control, although I may convert to a custom control since I have more
experience with those and have generally had better luck with them. I only
created a user control because I thought it would be quicker.

Colin

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:vg**************@cpmsftngxa06.phx.gbl...
Hi Colin,

Based on my research and experience, I would like to share the following
information with you.

Before the Page_Load event, asp.net loads in all the ViewState data, for
example, recreating your controls on web page. Then it matches up the
control that raises the postback with the actual control which was
regenerated from the ViewState. At this point, ASP.NET knows that this
particular control was fired and it adds the handler event to the list of events that must be executed.

If the load phase was after the restore of the ViewState data, the event
will not fired as expected.

The ASP.NET page framework provides a technique called event bubbling that allows a child control to propagate events up its containment hierarchy.
Event bubbling enables events to be raised from a more convenient location in the controls hierarchy and allows event handlers to be attached to the original control as well as to the control that exposes the bubbled event.
For more information, plesae check this article:

Bubbling an Event

http://msdn.microsoft.com/library/en...lingcommandeve
nt.asp

Does it answer your question? If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 17 '05 #4

P: n/a
Hi Colin,

I am sorry if there is any misunderstanding.

After reviewing your response, I have a little puzzle on your issue.

As I understand, you developed a UserControl, an ascx file, which contains
a Calendar server control. Then you instantiate the user control in a web
page.

In another web page, you use the Server.Transfer to invoke the web page
where the user control was located.

However, the problem is that in this situation, some events on the Calendar
inside the user control are not fired as expected.

On my side, to reproduce the issue, I did the following tests.

1. Create a web user control, a class inherits from
System.Web.UI.UserControl.
2. Drag and drop a Calendar control onto the user control.
3. Put a Response.Write statement inside the SelectionChanged handler of
the calendar control.
4. Create a web page and drag the ascx file (the user control) onto this
web page.
5. Create another webpage, which contains a button. In the click event of
the button, I just do the following thing:

Server.Transfer("the web page where the user control was located")

6. Set the web page created in step 5 as the start web page. Compile and
run the application. When the web page launches up, click the button to
trigger the Servevr.Transfer.
7. When the web page where the user control comes up, I click certain day
on the Calendar control, the SelectionChanged event is fired successfully.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #5

P: n/a
Hi Colin,

I am sorry if there is any misunderstanding.

After reviewing your response, I have a little puzzle on your issue.

As I understand, you developed a UserControl, an ascx file, which contains
a Calendar server control. Then you instantiate the user control in a web
page.

In another web page, you use the Server.Transfer to invoke the web page
where the user control was located.

However, the problem is that in this situation, some events on the Calendar
inside the user control are not fired as expected.

On my side, to reproduce the issue, I did the following tests.

1. Create a web user control, a class inherits from
System.Web.UI.UserControl.
2. Drag and drop a Calendar control onto the user control.
3. Put a Response.Write statement inside the SelectionChanged handler of
the calendar control.
4. Create a web page and drag the ascx file (the user control) onto this
web page.
5. Create another webpage, which contains a button. In the click event of
the button, I just do the following thing:

Server.Transfer("the web page where the user control was located")

6. Set the web page created in step 5 as the start web page. Compile and
run the application. When the web page launches up, click the button to
trigger the Servevr.Transfer.
7. When the web page where the user control comes up, I click certain day
on the Calendar control, the SelectionChanged event is fired successfully.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #6

P: n/a
I'm also using URL rewriting. I encountered the problem detailed in KB
Q817036. The work-around presented in that article has cleared up the
problem for me.

Thanks for taking the time to investigate my issue.

Colin

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:wa*************@cpmsftngxa06.phx.gbl...
Hi Colin,

I am sorry if there is any misunderstanding.

After reviewing your response, I have a little puzzle on your issue.

As I understand, you developed a UserControl, an ascx file, which contains
a Calendar server control. Then you instantiate the user control in a web
page.

In another web page, you use the Server.Transfer to invoke the web page
where the user control was located.

However, the problem is that in this situation, some events on the Calendar inside the user control are not fired as expected.

On my side, to reproduce the issue, I did the following tests.

1. Create a web user control, a class inherits from
System.Web.UI.UserControl.
2. Drag and drop a Calendar control onto the user control.
3. Put a Response.Write statement inside the SelectionChanged handler of
the calendar control.
4. Create a web page and drag the ascx file (the user control) onto this
web page.
5. Create another webpage, which contains a button. In the click event of
the button, I just do the following thing:

Server.Transfer("the web page where the user control was located")

6. Set the web page created in step 5 as the start web page. Compile and
run the application. When the web page launches up, click the button to
trigger the Servevr.Transfer.
7. When the web page where the user control comes up, I click certain day
on the Calendar control, the SelectionChanged event is fired successfully.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #7

P: n/a
I'm also using URL rewriting. I encountered the problem detailed in KB
Q817036. The work-around presented in that article has cleared up the
problem for me.

Thanks for taking the time to investigate my issue.

Colin

"Jacob Yang [MSFT]" <ji***@online.microsoft.com> wrote in message
news:wa*************@cpmsftngxa06.phx.gbl...
Hi Colin,

I am sorry if there is any misunderstanding.

After reviewing your response, I have a little puzzle on your issue.

As I understand, you developed a UserControl, an ascx file, which contains
a Calendar server control. Then you instantiate the user control in a web
page.

In another web page, you use the Server.Transfer to invoke the web page
where the user control was located.

However, the problem is that in this situation, some events on the Calendar inside the user control are not fired as expected.

On my side, to reproduce the issue, I did the following tests.

1. Create a web user control, a class inherits from
System.Web.UI.UserControl.
2. Drag and drop a Calendar control onto the user control.
3. Put a Response.Write statement inside the SelectionChanged handler of
the calendar control.
4. Create a web page and drag the ascx file (the user control) onto this
web page.
5. Create another webpage, which contains a button. In the click event of
the button, I just do the following thing:

Server.Transfer("the web page where the user control was located")

6. Set the web page created in step 5 as the start web page. Compile and
run the application. When the web page launches up, click the button to
trigger the Servevr.Transfer.
7. When the web page where the user control comes up, I click certain day
on the Calendar control, the SelectionChanged event is fired successfully.

If I have misunderstood your concern, please feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! 每 www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.