Interaction between user controls?

J

Jonas

Hi,

I have a couple of search criteria’s in one web user control (.ascx) and I want to post them do the server and view the result in another web user control on the same .aspx page. Depending on the criteria I will return an arraylist of results. (=I will bind a datagrid.

How can I call a function in another web user control
I don’t want to but the search criteria’s in the cache
I have seen the delegate example on 4guys, but I wonder if there is another way
 
M

Michael Tkachev

Hi,

this sample will show how you can get event from the usercontrol in the
form.

---------- *.ascx -------------
public event EventHandler OnClick; // Public event. It allows you catch
this event on the form.

// This event for a button in the usercontrol.
protected void myClick(object sender, EventArgs e)
{
if(OnClick != null)
OnClick(ItemID, new EventArgs());
}
---------- end *.aspx.cs -------------
---------- *.aspx.cs -------------
protected Controls.Tree Tree1; // It's my usercontrol.

// This methd works when you click buton in the user control
protected void Click_Control(object sender, EventArgs e)
{
// Here must be your code
}
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.Tree1.OnClick += new System.EventHandler(this.Click_Control);
}
---------- end *.aspx.cs -------------

If you will change this code you will be able to get your solution. :)

Bye

Michael


Jonas said:
Hi,

I have a couple of search criteria's in one web user control (.ascx) and I
want to post them do the server and view the result in another web user
control on the same .aspx page. Depending on the criteria I will return an
arraylist of results. (=I will bind a datagrid.)
 

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,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top