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 7 1316
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
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
"Michael Groeger" <go*********@we b.de> wrote in message
news:c6******** *************** ***@posting.goo gle.com... 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
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?
<nm*****@gmail. com> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.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
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" <johnwsaundersi ii at hotmail.com> schrieb im Newsbeitrag
news:e4******** ******@tk2msftn gp13.phx.gbl... "Michael Groeger" <go*********@we b.de> wrote in message news:c6******** *************** ***@posting.goo gle.com... 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
I am only new to asp.net not to .net at all ;-)
<nm*****@gmail. com> schrieb im Newsbeitrag
news:11******** *************@c 13g2000cwb.goog legroups.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? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 postback, and it is. However,
I've noticed an intriguing thing which I think might be at the root of the
problem.
My page inherits from a basepage, which in turn inherits from
System.Web.UI.Page. On initial load, the events fire something like...
|
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 references as to how to do it this way as I already know how.
I know this may be getting into advanced or unheard of territory.
I have some custom web user controls that are dynamically created at run time along with other controls. I can still add an...
|
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
|
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 Me.plcTabViews.Controls.Add(LoadControl("test.ascx")). There
are up to 30 possibilities which are decided by CASE statements and keeps
one from loading up onto another. However, I'm running into a unique
error...
Failed to load viewstate. The control tree into which viewstate is...
|
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 inside the server
control when it is clicked on.
however when I click on a button at present I get an error saying that the
An error has occurred because a control with auto-generated id
| |
by: Shimon Sim |
last post by:
I have a custom composite control
I have following property
|
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 control in
my aspx page with two image buttons, one for an edit command, another a
delete command. Here is a cut down code fragment.
...
|
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 been able to find the cause of the problem, and will describe it here first textually and then through a code example.
The purpose of what I am trying to do is to create a postback-free web application through the use of ASP.net AJAX UpdatePanels...
|
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 relative to the hosting Page, and
therefore if the following specific arrangement would even work.
What I'm looking to do is dynamically insert multiple custom composite Web
server controls onto a blank Page. This is no problem, I know how to do...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |