Knowing who fired an event in Page_Load

Hyuga

Freshman
Joined
Jul 21, 2005
Messages
30
Hello everybody,

I want to know if it is possible to know which control of the form has fired an event while staying in the Page_Load routine. I know that we can know the control in the handler of the event, but I need to know it in Page_Load.

Any idea?

Thanks for your help
 
Only if the page load function handles the event and the event fired must use the standard delegate.

Whatever you are trying to do, you will be able to achieve it a different way. Start by describing the problem.
 
The problem

Ok, let's see if I can explain my problem accurately.

The situation:
My page have two controls, a treeview and a placeholder. The placeholder will contain one or more custom controls (basicly a customized Datagrid).

How it works:
The user can navigate through the TreeView Nodes, and when he click in determinate branches, the program add some number of custom controls to the PlaceHolder (depending on some internal logic). When he click another node, the Placeholder is cleared and charged with some new customized datagrids. In the Datagrids there are Image Buttons that, when you click on it, executes a database update and changes the ImageURL of them.

The problem:
When I start to navigate, everything works fine. I click on a node, the datagrids appear, I click one of the ImageButtons and the logic executes correctly. But when I try to charge the customized controls that corresponds to another TreeNode, the event from the ImageButton doesn't fire.

The cause of the problem:
When the page load after the second click on the treenode, I reload the PlaceHolder with the previous customize controls in Page_Load, then the subroutine fired by the SelectedIndexChange of the treeview executes and try to reload again the Placeholder.
First of all I try to clear the Placeholder with a Controls.Clear(), and then recharge it. Visually, that worked and I can see only the controls desired, but programatically, it doesn't work. If I look in the Trace information of the loaded page, the controls inside the placeholder started with and index _ctlX (where X is some number <> 0) insted of starting with the _ctl0 as it should be. This X depends on how many controls have been charged in the Page_Load. If 5 controls have been added in Page_Load, in the event handler of OnSelectIndexChange the first control added has the index _ctl5.


What I am trying to achieve:
If I can detect, in the Page_Load, that an OnSelectedIndexChange event has been fired, I can avoid the first Placeholder charge, and this will solve my problem


I Hope that my explanation was clear, my english is not very good, sorry.
 
Last edited:
My problem has been solved, but I'm interested in the original question, if anyone has any idea of what I'm trying to explain :D

If interested, I've solved the problem having a hidden field with the code of the last node of the tree selected, and in the Page_Load, comparing this field with the treeview.selectedNodeIndex property. Easy, but I've wasted 4 days trying to find the solution :(
 
Back
Top