473,396 Members | 1,929 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,396 software developers and data experts.

Event within an Event Issue

Using asp.net 2.0 I have a web project with one page which contains 2
user controls. One user control is a message bar with a label control
and the other user control that contains a treeview control.

I created an event on the tree user control to publish any error
messages back to the page. The page in turn will call a method on the
message bar control to show the message in the label.

The tree control has some nodes populate during On_Load no problem. One
node has its child nodes populated from a database. I do this using the
treeview event OnTreeNodePopulate.

The problem is during the processing of the OnTreeNodePopulate event I
fire the event to publish an error message but the message bar label is
not updated. I've traced the code and the error message event is passed
to the page which calls the message bar control which updates label
control with the error text, but when the page is returned there is no
text in the label still.

My only thought is maybe because i'm firing an event (my error event)
within an event (tree's OnTreeNodePopulate event) that is somehow the
issue?

Thanks in advance

Sep 15 '06 #1
1 1839
Simplified the example. Forget the user controls. The behavior exists
simply trying to update a label on the page from the tree control's
OnTreeNodePopulate event with an event. Very simple code below
reproduces the behavior. Ideas???

-----------default.aspx------------
<%@ Page Language="C#" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
this.MessageEvent += new
MessageEventHandler(HandleMessageEvent);
}

public void HandleMessageEvent(string msg)
{
MessageLabel.Text = msg;
}

public void OnPopulate(Object sender, TreeNodeEventArgs e)
{
OnMessageEvent("populating");
}

public delegate void MessageEventHandler(string msg);
public event MessageEventHandler MessageEvent;
public void OnMessageEvent(string msg)
{
if (MessageEvent != null)
MessageEvent(msg);
}
</script>

<html>
<head runat="server"><title>Test</title></head>
<body>
<form id="form1" runat="server"><div>
<asp:TreeView ID="TreeControl" runat="server"
OnTreeNodePopulate="OnPopulate">
<Nodes>
<asp:TreeNode Text="Root" Expanded="False"
PopulateOnDemand="true"></asp:TreeNode>
</Nodes>
</asp:TreeView>
<asp:Label ID="MessageLabel" runat="server"
Text=""></asp:Label>
</div></form>
</body>
</html>

Sep 16 '06 #2

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

Similar topics

2
by: Daniel Bickett | last post by:
Hello, I am writing an application using two event-driven libraries: wxPython, and twisted. The first problem I encountered in the program is the confliction between the two all-consuming...
3
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind...
19
by: Heidi Hundåla | last post by:
Hi ! I have a Wep App in C#. Page_Unload fires after Page_Load, and it seems totally unreasonable when you want to use this event when you _leave_ the page. In my project we wanted to use...
5
by: csgraham74 | last post by:
Hi guys, I posted regarding this issue the other day but i still dont have an answer to my problem. Basically i have imported asp.net pages from dreamweaver into visual studio. Ive added a...
12
by: Jack Russell | last post by:
My unstanding of all VB up to and including vb6 is that an event could not "interrupt" itself. For instance if you had a timer event containing a msgbox then you would only get one message. ...
15
by: prabhdeep | last post by:
Hi, Can somebody explain, why in following code, i get "event not defined" error funcTest(sMenu) { doument.getElementById('id1').addEventListener('mousedown', function(){ click(sMenu,...
8
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
5
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
Hi, I have a strange issue occurring with LinkButtons that are dynamically added to each (data) row of my DataGrid on that grid's ItemDataBound event. Each LinkButton is assigned its own event...
7
by: Gary Brown | last post by:
Hi, I have a computation intensive application that tries to update the display quite often. After a few seconds the window stops updating and the window goes blank. A breakpoint in the Paint...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.