Problem: Custom control receives postback events for other controls

L

Lamont Adams

Hi all,

I've created numerous custom controls of varying complexity, but I've been
on this problem for a day and a half, and I can't figure this mystery out. I
hope one of you kind folks can point out the really obvious and stupid thing
I'm overlooking here. :)

I have a custom control that provides a tasklist similar to what you get in
certain parts of Office. On the client it consists of a bunch of nested,
named and id'ed divs with onclick event handlers wired to call __doPostBack
with the control's server-side ID and a task name and task Id as arguments
(example for a control named Tasks: __doPostBack("Tasks",
"CreateNewProject;task1")). The server control implements
IPostbackEventHandler to raise a TaskClick event into the hosting page. This
control's content is generated from an XSLT transform of a page-supplied XML
file that's written directly to the response stream in RenderContents. It
doesn't contain any child controls, or do anything else fancy beyond storing
a handful of string properties in its viewstate.

Here's the thing: This control's RaisePostbackEvent method is being called
on each and every submit/postback of the form. The way I understand the
postback mechanism, this shouldn't be happening. I'm fuzzy on submit
buttons, but for controls that invoke __doPostBack on the client, the
framework figures out which control to raise the event on from the
__EVENTTARGET form field, and looks for an IPostbackEventHandler implementer
that has the right ID, right? Well, Request.Form("__EVENTTARGET") always has
the correct control's ID in it, not the taskview control's, but the taskview
gets the event every time anyway.

If I put a button control on the same form as the tasklist control, and wire
an event handler in the page's codebehind, the button's click event never
fires. If I put a label control on the page and wire a click event handler,
it never fires. If I put one of my other custom controls on the page and
wire an event handler for it, the handler never fires. If I put a breakpoint
in the tasklist control's RaisePostBackEvent method, I see why: tasklist's
RaisePostBackEvent method is being called for any postback on the page
hosting the control.

If I remove the taskview control from the page and recompile then all my
event handlers fire as expected. So it has to have something to do with that
control, but I've been over and over it and can't find a problem: it's
really a simple control. I'm out of ideas... anyone else have any?

Thanks in advance!
 
L

Lamont Adams

Nobody has any ideas? At least confirm for me that this shouldn't be
happening... anyone?
 

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

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top