views:

1541

answers:

4

I have a custom control that implements IPostBackEventHandler. Some client-side events invoke __doPostBack(controlID, eventArgs).

The control is implemented in two different user controls. In one control, RaisePostBackEvent is fired on the server-side when __doPostBack is invoked. In the other control, RaisePostBackEvent is never invoked. I checked the __EVENTTARGET parameter and it does match the ClientID of the control... where else might I look to troubleshoot this?

+1  A: 

There's a lot of ways this can fall apart. Are you adding the control to the page dynamically in code behind? If so alot of times your UniqueID can be off - even though the client id's are equal. Do you have a code sample that might demonstrate what you're doing?

brendan
A: 

Double check that it is indeed a derivation of the UserControl class, not the WebControl one.
This one has had me by surprise many times. If you need to use WebControl for the styling, you need to let your control implement INamingContainer. (Don't worry, its a marker interface)

So..

public class MyControl : UserControl {}

Or

public class MyControl : WebControl, INamingContainer {}
Lars Mæhlum
+1  A: 

Well I feel kind of stupid... it was a simple problem - I thought the UniqueID of the control matched __EVENTARGS but due to some JavaScript goofiness on my part, it had one $ where an underscore should have been. It was an extremely long UniqueID so easy to overlook.

Rex M
A: 

Hi,

I am using RADScheduler, and it is in a usercontrol (say Month.ascx). I have created a usercontrol (say Template.ascx) for AppintmentTemplate, and I added the following code for the click event of the template user control (Template.ascx).:

Me.parentDiv.Attributes.Item("OnClick") = Me.Page.ClientScript.GetPostBackEventReference(Me, "Click")

In Template.ascx, I implemented IPostBackEventHandler and RaisePostBackEvent. Now I want catch the bubble event in Month.ascx OnBubbleEvent. as below:

Protected Overrides Function OnBubbleEvent(ByVal sender As Object, ByVal e As EventArgs) As Boolean Return False ' To return to the parent aspx page. End Function

The Click event on Template User control is raising the postback, but I am not able to catch the bubbleevent on the month user control's OnBubbleEvent...

Waiting for your reply... Thanks

GDS, this is not a discussion forum - if you have a new question, please post it as a new one (click "Ask Question" at the top-right of the page)
Rex M