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

How do you capture User control events in the parent page

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 on one user
control to make another user control invisible. How can the parent
aspx page capture that click event so that it can know to do
something. thanks
Nov 18 '05 #1
2 2783
The proper way to do is is to have the usercontrol raise an event the page
can hook into. Something like this would go into your usercontrol:

protected System.Web.UI.WebControls.Button hide;
public event EventHandler onHideClick;

private void hide_Click(object sender, System.EventArgs e) {
if (this.onHideClick != null){
this.onHideClick(this, e);
}
}
and then your page could hook into the onHideClick event:
uc1.onHideClick +=new EventHandler(uc1_onHideClick);

private void uc1_onHideClick(object sender, EventArgs e) {
//do stuff
}

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
<jw*****@gmail.com> wrote in message
news:d3**************************@posting.google.c om...
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 on one user
control to make another user control invisible. How can the parent
aspx page capture that click event so that it can know to do
something. thanks

Nov 18 '05 #2
This doesn't appear to work. Whenever the button of the user control
is clicked, this event is not recognized and the code is not executed
in the click method, so the onHideClick event is not raised, and any
other code in the button Click method is not called.

"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message news:<Ou**************@TK2MSFTNGP10.phx.gbl>...
The proper way to do is is to have the usercontrol raise an event the page
can hook into. Something like this would go into your usercontrol:

protected System.Web.UI.WebControls.Button hide;
public event EventHandler onHideClick;

private void hide_Click(object sender, System.EventArgs e) {
if (this.onHideClick != null){
this.onHideClick(this, e);
}
}
and then your page could hook into the onHideClick event:
uc1.onHideClick +=new EventHandler(uc1_onHideClick);

private void uc1_onHideClick(object sender, EventArgs e) {
//do stuff
}

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
<jw*****@gmail.com> wrote in message
news:d3**************************@posting.google.c om...
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 on one user
control to make another user control invisible. How can the parent
aspx page capture that click event so that it can know to do
something. thanks

Nov 18 '05 #3

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

Similar topics

2
by: msnews.microsoft.com | last post by:
It appears myButton_OnClick is triggering in my user control AFTER its parent's Page_Load already runs. Is there a way to make the parent Page_Load to run afterwards? I'm changing a session...
6
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...
0
by: ab_j | last post by:
I have a user control that contains a dropdown which I want to use as a menu on multiple .aspx pages. Basically, all I am trying to do is pass the selected value of the dropdown in the user...
6
by: Art | last post by:
Hi I'm new at this and need some help. I have a "solution" with 2 projects - the main project and a library. The library is simple, it contains a text box that will appear many times in the form...
2
by: Mike | last post by:
Hi, I am strugling with a simple problem which I can't seem to resolve. I have an asp.net page which contains a server-control (flytreeview, which is a kind of a tree to be exact). The tree is...
1
by: David Lozzi | last post by:
Hello, I have a user control that saves data. When the data is saved, I need to call a function in the parent page from the user control to initiate something else. I know I can set it up so...
1
by: engwar | last post by:
I have a page that my users will go to to upload files to my website. As I want to reuse the file upload code on multiple pages I put the file upload textbox/buttons on a user control which I plan...
0
by: davidr | last post by:
Hi, I've read about bubble events and setting up the event args and several other methods to have an event that occurs in a usercontrol flow up to the parent. The problem is each one entails a...
8
by: Larry Smith | last post by:
Hi there, Can someone enlighten me on how to trap a keystroke in my "PropertyGrid" override. I see functions or properrites at the control or form level called: OnKeyDown OnKeyPress OnKeyUp...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.