accessing other web controls properties

D

dmalhotr2001

Hi,

I have 2 web controls:

one.ascx
two.ascx

one.ascx is embedded within two.ascx.
one.ascx has a button called clear within it. This clear button posts
back when pressed.
both these user controls are within the same aspx page.


I want to know within two.ascx when the clear button is pressed within
one.ascx. I want to know what button was pressed within one from two.

I have tried this:

Within two.ascx I've tried this in code behind:
one one_control = (one)this.FindControl("one");

I can access some of the properties now within one from two however I
want to know when the clear button is pressed within one.

How do I tell this.


Thanks

:D
 
K

Kirk Jackson

I want to know within two.ascx when the clear button is pressed within
one.ascx. I want to know what button was pressed within one from two.

I have tried this:

Within two.ascx I've tried this in code behind:
one one_control = (one)this.FindControl("one");

I can access some of the properties now within one from two however I
want to know when the clear button is pressed within one.

Hi D,

Rather than coupling your two controls tightly together, I'd suggest that
one control raises an event when the button is pushed, and the containing
page subscribes to that event in the same way that the page would receive
button click events in an event handler. Then the page can call a method on
the second control.

I think this article explains the concept:

http://codebetter.com/blogs/brendan.tompkins/archive/2004/10/06/27795.aspx

Kirk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,119
Latest member
IrmaNorcro
Top