Hi,
This is frying my brain.
I have a user control with a menu inside, when the user clicks a linkbutton I would like to update a panel in the main page.
How do I create the proper trigger to update the panel.
Thanks.
7 5332
You will have to create an event that your user control fires, and then catch it in the containing control.
In your custom control, add the following code (this code assumed that it is a click event): -
public event ClickHandler MyClickEvent;
-
Then, when you want to fire the event, simply add the code:
This event will then be added to the Events list of your control, simply add the handler for the event like you would a normal event, where myClickEventHandler is the handler method written in your containing control: -
this.MyClickEvent += new ClickHandler(myClickEventHandler);
-
Hi RoninZA,
Thanks for your response!
Declaring the ClickEventHandler solved most of my problem. Thanks for that.
I wasn't sure how to initialize the Event in my UpdatePanel (ajax asynchronouspostback). So I used OnClickEvent on my control and referenced this in my UpdatePanel Trigger. This worked well.
But even though my problem is fixed I've unfortunately missed out on undertsanding how to initialize an Event control.
Could you enlighten me.
Thanks again.
Only a pleasure rsdev :)
An event is NOT a control... it is an event, and so can not be initialised, but only 'fired', and 'caught'.
C#, VB, and all, OK, let me say MOST (before someone tries to correct me with some arb other language) other visual languages are event-based, as opposed to procedural/linear. Where linear applications have implicit start and end points, and run only from the start to the end, event-based programming involves the firing and catching of events, and the executing of pockets of code as the events occur. An event can be a click, mouse-over, form refresh, etc (look in the events list of a control for examples). Also, custom events can be written to be fired from a custom control... for (a silly) example a 'seven_found' event can be fired from your own counter class when the counter reaches any multiple of seven, and that event can be caught by the object that initialised the counter. There is a LOT of documentation on the net about events in your preferred language, just have a mosey on over to Google and do a search.
I hope I haven't mis-uderstood your question after all this typing!
Hehe, creating my own events was something I had never learned to do.
Is there a way to tell if it's been handled or not? Like throw a "NotHandled" error if the event fires and it's not handled? -
public event ClickHandler MyClickEvent;
-
Then, when you want to fire the event, simply add the code:
No, because a LOT of events are fired, but not necessarily handled, while code is running, events that are not handled can not be identified... at least, not as far as I know.
I suppose if you REALLY wanted to know you could build some event tracking system in, but you'd really have to have a lot of spare time on your hands! :D
Thanks RoninZA!
I have solved my original problem. Excuse my bad terminology, I am still a novice when it comes to server-side scripting.
Not sure if this is a question for another post!
I would like to change the mode of gridview to 'edit' using javascript onclick event from an update panel? Is this possible.
Thanks again.
Sorry rsdev, my web dev experience is pretty limited, so I'm not so sure - best start a new thread!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Lance Johnson |
last post by:
I would like for when a tab page changes, that my controls on the previous
tab page would receive a visiblechanged event or some other event so they
are aware of that. We have db locks in some of...
|
by: George Durzi |
last post by:
I have a simple user control with a text box and a submit button. When the
user enters some text into the textbox and clicks the submit button, a
record is created in the database.
I'm using...
|
by: mawi |
last post by:
Hi there,
When removing page children controls created dynamically
not in last-to-first order, the close button of the last
control looses its event wiring, even though the handler is
rewired...
|
by: jw56578 |
last post by:
Hi,
How would the following be accomplished. I have a parent aspx page,
that dynamically loads 3 user controls (through LoadControl) depending
on a certain criteria. I want the click of a button...
|
by: grist2mill |
last post by:
I want to create a standard tool bar that appears on all pages that is
a control. The toolbar has a button 'New'. What I wolud like when the
user clicks on 'New' depends on the page they are on. I...
|
by: Rob Morgan |
last post by:
I have a grid and a user control on the same page. The user control has a
save button that triggers a click event server side. Once the click event
happens the page renders, but I need to update...
|
by: Demetri |
last post by:
I'm trying to determine if we want to use panels or user controls for our
pages. Our primary concern is performance, page loading and posting speed.
To illustrate my question, lets use the...
|
by: davidr |
last post by:
Hi,
I have a panel that I load user Control in no problem. The problem
arrises when I do a post back on one of these user controls. I have
button it does a click event. In this click event I...
|
by: davidr |
last post by:
Hi,
I been stuck on this for a week or more. So please help!
I have a menu were a user can click a button and a user control is
loaded into the page. A problem occurs when trying to load a...
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |