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

How to control controls postback sequence?

Hi all,

I have designed user controls. One search control where I can search
for items in the database and show them in a grid. This control also
has a button which simply exposes it's click event.

When clicking on the button in this control i want to add the selected
rows in the grid to another grid, which is on my second control. I do
this by handling the Click event of the button in my page and add the
values to arraylist in the session cache. The second control takes
this arraylist and fills its grid with the values from it.

My problem now is, that i cannot determine the sequence of the
postbacks. The event handler for the postback event of my second
control is invoked before the postback event handler of my first
control, so that the selection is not made visible to the client.

How can I control the sequence?

Kind regards,
Michael Groeger
Nov 19 '05 #1
7 1300
All controls will receive the Load event first. Then the postback
events (click in your case) will be fired. Then the PreRender events
will be fired.

The easiest thing for you to do would be to handle the array in the
PreRender event of the control. By the time this is fired all other
control events will have happened

Nov 19 '05 #2
All controls will receive the Load event first. Then the postback
events (click in your case) will be fired. Then the PreRender events
will be fired.

The easiest thing for you to do would be to handle the array in the
PreRender event of the control. By the time this is fired all other
control events will have happened

Nov 19 '05 #3
"Michael Groeger" <go*********@web.de> wrote in message
news:c6**************************@posting.google.c om...
Hi all,

I have designed user controls. One search control where I can search
for items in the database and show them in a grid. This control also
has a button which simply exposes it's click event.

When clicking on the button in this control i want to add the selected
rows in the grid to another grid, which is on my second control. I do
this by handling the Click event of the button in my page and add the
values to arraylist in the session cache. The second control takes
this arraylist and fills its grid with the values from it.


I would recommend that you not do that.

I would recommend that your first control should expose a property of type
ArrayList (or perhaps of IList or ICollection, for generality). I'd have
the Click event of the button in your first control put the values into the
ArrayList property before it raises the Click event of your first control.
When the Page receives the Click event, it can take the ArrayList from the
property in the first control and can put it into the corresponding property
on the second control. You'll have to add the latter.

The general pattern I like is to have the controls notify the Page of any
events from within them, and to allow the Page to read values from the
controls and possibly write values to other controls. That's similar to the
Mediator Pattern.

John Saunders
Nov 19 '05 #4
That is a much better suggestion, much more scaleable and reusable,
however more complicated for a beginner to implement as they need to
learn how to create their own events for their custom control. Hence
why I suggested the quick workaround of simply moving the existing code
to PreRender.
Do you specifically think this would not work for any reason?

Nov 19 '05 #5
<nm*****@gmail.com> wrote in message
news:11*********************@c13g2000cwb.googlegro ups.com...
That is a much better suggestion, much more scaleable and reusable,
however more complicated for a beginner to implement as they need to
learn how to create their own events for their custom control. Hence
why I suggested the quick workaround of simply moving the existing code
to PreRender.
Do you specifically think this would not work for any reason?


No, I just think that creating your own controls isn't a beginner work. By
the time you're doing your own controls (even user controls if they have
codebehind), you should be able to create your own events given an example.

Besides, it's nice to set a good example for beginners: they may follow your
example for the rest of their careers!

John Saunders
Nov 19 '05 #6
John,

thanks for your reply!

I don't liked the solution I thought of too. I understand your solution but
what I don't like is the way we have to implement things. When implementing
asp.net first time you should rely on that if a control exposes a click
event you probably should take actions there once the control gets clicked.
Now, I have to do things in Load or PreRender where I do not exactly know if
the control really got clicked. I certainly understand that this is an issue
which may happen rather rarely.

But okay, your suggested solution seems to work. Thanks for that ;-)

Michael Groeger

"John Saunders" <johnwsaundersiii at hotmail.com> schrieb im Newsbeitrag
news:e4**************@tk2msftngp13.phx.gbl...
"Michael Groeger" <go*********@web.de> wrote in message
news:c6**************************@posting.google.c om...
Hi all,

I have designed user controls. One search control where I can search
for items in the database and show them in a grid. This control also
has a button which simply exposes it's click event.

When clicking on the button in this control i want to add the selected
rows in the grid to another grid, which is on my second control. I do
this by handling the Click event of the button in my page and add the
values to arraylist in the session cache. The second control takes
this arraylist and fills its grid with the values from it.
I would recommend that you not do that.

I would recommend that your first control should expose a property of type
ArrayList (or perhaps of IList or ICollection, for generality). I'd have
the Click event of the button in your first control put the values into

the ArrayList property before it raises the Click event of your first control.
When the Page receives the Click event, it can take the ArrayList from the
property in the first control and can put it into the corresponding property on the second control. You'll have to add the latter.

The general pattern I like is to have the controls notify the Page of any
events from within them, and to allow the Page to read values from the
controls and possibly write values to other controls. That's similar to the Mediator Pattern.

John Saunders

Nov 19 '05 #7
I am only new to asp.net not to .net at all ;-)

<nm*****@gmail.com> schrieb im Newsbeitrag
news:11*********************@c13g2000cwb.googlegro ups.com...
That is a much better suggestion, much more scaleable and reusable,
however more complicated for a beginner to implement as they need to
learn how to create their own events for their custom control. Hence
why I suggested the quick workaround of simply moving the existing code
to PreRender.
Do you specifically think this would not work for any reason?

Nov 19 '05 #8

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

Similar topics

1
by: Karl Seguin | last post by:
i have a dynamically created user control which contains a non-dynamically created ASP.Net button. When the button is clicked, the event is not fired. I know that the control must be created on...
5
by: Dan | last post by:
Hi, I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no...
2
by: John Lau | last post by:
Hi, Is there documentation that talks about the page lifecycle, the lifecycle of controls on the page, and the rendering of inline code, in a single document? Thanks, John
1
by: John Cosmas | last post by:
I've got a page which loads up a different user control into a placeholder control every time a button is clicked on the parent page. I use a statement like...
1
by: Martin | last post by:
Hi, I have produced a custom server control that simple outputs a row of 26 buttons, one button for each letter of the english alphabet. now what I would like to do is catch the button click...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
2
by: ChrisCicc | last post by:
Hi All, I got a real doozy here. I have read hundreds upon hundreds of forum posts and found numerous others who have replicated this problem, but have yet to find a solution. Through testing I have...
1
by: Jordan S. | last post by:
I'm just wondering if this would work. Please note that I'm not asking *how* to raise events. I'm clear on that. What I'm not clear on is the sequence in which events are raised by custom controls...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
1
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
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
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,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.