UserControl

A

Angel

Hi
I created UserControl which have some events.
I dragged and dropped it to the page but a reference to this control did not
appear in the code behind.
Only references to other VC components appeared
How can I get a reference to this control from then code behind if VS did
not automatically placed reference to usercontrol the page class definition.
I would need this reference(MyUserControl) to set a EventHandler like this

private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
this.MyUserControl.ItemSelected += (this.ItemSelectedHolder);

}

Thanks
Angel
 
B

Bryant Hankins

If the designer is not adding the instance for you, you can just add it to
top of the code-behind page yourself. Make sure you give it the same name
that you gave it in the designer like:

protected UserControl2 MyUserControl;

This thread discusses creating a user control that raises events to its
container:
http://shrinkster.com/cf
 

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

Top