473,503 Members | 1,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Event handling with Web User Control

Hail the experts!!!

I'm creating a web user control which displays a hierarchical tree of
items from an xml string passed to the control (from the host page)
through an exposed property.
This xml gets created in the Page_Load method of the host page

Each tree item displayed by the control is a LinkButton object.

This LinkButton fires a CommandEventHandler event (when the user
clicks) that is consumed by the page hosting this control.

Everything perfect so far...

The user loads the page, clicks on one of the items, the event gets
fired, the page performs a postback...

Problem is:

When the host page receives the event fired by the tree control, I
would like at this point to get a different XML from the database, then
have the control redraw itself with a different tree.

But how can I do this, since by the time the event raised by the
control gets processed the Page_Load has already finished and the
control is already displaying the old tree?

If I try !IsPostBack in the Page_Load the event will not fire at all.

Basically my question is how in the heck can I update the tree control
from the event method in the host page other than having the page
reload itself using javascript for example?

Also, what is the use of Events in this scenario? Very little in this
case unless I am headed in the wrong direction completely!!!

Many thanks to all, I will post specific code if required, but for now
it's only concepts I need to clarify.

weBo

May 4 '06 #1
2 1517
Change the control such that when you assign the XML it doesn't build itself
immediaetly. Instead have the control wait to build itself until PreRender.

-Brock
http://staff.develop.com/ballen

Hail the experts!!!

I'm creating a web user control which displays a hierarchical tree of
items from an xml string passed to the control (from the host page)
through an exposed property.
This xml gets created in the Page_Load method of the host page
Each tree item displayed by the control is a LinkButton object.

This LinkButton fires a CommandEventHandler event (when the user
clicks) that is consumed by the page hosting this control.

Everything perfect so far...

The user loads the page, clicks on one of the items, the event gets
fired, the page performs a postback...

Problem is:

When the host page receives the event fired by the tree control, I
would like at this point to get a different XML from the database,
then have the control redraw itself with a different tree.

But how can I do this, since by the time the event raised by the
control gets processed the Page_Load has already finished and the
control is already displaying the old tree?

If I try !IsPostBack in the Page_Load the event will not fire at all.

Basically my question is how in the heck can I update the tree control
from the event method in the host page other than having the page
reload itself using javascript for example?

Also, what is the use of Events in this scenario? Very little in this
case unless I am headed in the wrong direction completely!!!

Many thanks to all, I will post specific code if required, but for now
it's only concepts I need to clarify.

weBo

May 6 '06 #2

Brock Allen wrote:
Change the control such that when you assign the XML it doesn't build itself
immediaetly. Instead have the control wait to build itself until PreRender.

-Brock
http://staff.develop.com/ballen

Hail the experts!!!

I'm creating a web user control which displays a hierarchical tree of
items from an xml string passed to the control (from the host page)
through an exposed property.
This xml gets created in the Page_Load method of the host page
Each tree item displayed by the control is a LinkButton object.

This LinkButton fires a CommandEventHandler event (when the user
clicks) that is consumed by the page hosting this control.

Everything perfect so far...

The user loads the page, clicks on one of the items, the event gets
fired, the page performs a postback...

Problem is:

When the host page receives the event fired by the tree control, I
would like at this point to get a different XML from the database,
then have the control redraw itself with a different tree.

But how can I do this, since by the time the event raised by the
control gets processed the Page_Load has already finished and the
control is already displaying the old tree?

If I try !IsPostBack in the Page_Load the event will not fire at all.

Basically my question is how in the heck can I update the tree control
from the event method in the host page other than having the page
reload itself using javascript for example?

Also, what is the use of Events in this scenario? Very little in this
case unless I am headed in the wrong direction completely!!!

Many thanks to all, I will post specific code if required, but for now
it's only concepts I need to clarify.

weBo


Hi Brock,

Thanks for the suggestion. I think I had tried that at some point
already.
Anyway I did an override of OnPreRender method for the control itself
and now the event is not being fired. The page does postback, but the
events are not fired.

What I had to do is save the whole xml damn thing to viewstate, so when
the control reloads it gets the xml from viewstate, then the event
simply adds more xml to it and tells the tree to add the new folders.

I'm not happy with this solution though. There must be a better way of
dealing with this situation I hope!

Thanks,

webO

May 8 '06 #3

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

Similar topics

18
2849
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
5
1697
by: Russell Smallwood | last post by:
Hello all, Why can't I wire up an event during the "Raise PostBackEvent" stage of a postback? Just in case this is the wrong question, the situation: deep in the bowls of some code-behind...
9
2314
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
15
26486
by: Amit D.Shinde | last post by:
I am adding a new picturebox control at runtime on the form How can i create click event handler for this control Amit Shinde
5
3328
by: Steve | last post by:
I have a datagrid in a WinForm. When the user edits an entry in the datagrid, after he leaves that field, I would like to do some cheking. What event fires when the user does that? I need to...
2
3815
by: Developer_Software | last post by:
Thanks in advance to anyone who can help :) I've got a placeholder control WITHIN A USER CONTROL that has its contents dynamically added and removed at runtime by a regular .aspx page. At...
3
1545
by: c676228 | last post by:
Hi all, I have an event in user control email to handling email change when user want to change the input for email address. Here it is In email.ascx.vb: Protected Sub UpdateEmail(ByVal sender As...
1
4510
by: EricRybarczyk | last post by:
I am starting a rewrite of an existing Classic ASP web site in ASP.NET 2.0. The existing ASP application has several types of users, each with a separate login process (separate login page,...
1
108670
Frinavale
by: Frinavale | last post by:
Introduction I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
0
7202
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
7278
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
7328
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
7458
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5578
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,...
1
5013
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.