473,383 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem: Custom control receives postback events for other controls

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!

Nov 18 '05 #1
1 1953
Nobody has any ideas? At least confirm for me that this shouldn't be
happening... anyone?

"Lamont Adams" <lamontadams1atyahoo.remove.dotcom> wrote in message
news:ef*************@TK2MSFTNGP12.phx.gbl...
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!

Nov 18 '05 #2

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

Similar topics

1
by: neil S via DotNetMonster.com | last post by:
I have a custom control with a textbox and dropdown list. The dropdown list is hidden and acts as a data source for the textbox. When the user enters text in the textbox, an onKeyup event is...
0
by: spacehopper_man | last post by:
hi - I am writing a "tab" control. - but it's losing the viewstate of the content pane when I switch between tabs. can anyone shed any light on why I'm losing ViewState based on my simple...
5
by: Alan Silver | last post by:
Hello, I have a products page that takes a product ID in the query string. Based on the product details (from a database), the page then loads up one of a number of custom controls, calls a...
0
by: Remy | last post by:
Hello I've built my own ASP.NET 2.0 Web User Control that uses the Atlas Ajax UpdatePanel. This works fine so far. The problem is if I embed this control with other control on a page and now I...
9
by: Rob | last post by:
When a custom control is used within a form, that control does not get events directly. I've run into this a couple times with both mouse and keyboard events. Ex: A custom control inherits from...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
2
by: forest demon | last post by:
i'm trying to create a custom control that contains multiple controls of different types(textbox, combox, checkbox, etc..) the examples i see derive from one type....for instance TextBox....
7
by: adiel_g | last post by:
Hello Everyone, I created a custom control. On the CreateChildControls, I added a textbox to the control as follows: // TextBox TextBox txtValue = new TextBox(); txtValue.ID = "txtValue"; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.