Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Referencing Dynamically created controls

Reply
Thread Tools

Referencing Dynamically created controls

 
 
Chris Kennedy
Guest
Posts: n/a
 
      04-12-2004
Can anyone tell me how to reference a a control, e.g. a control I have added
to the controls collection without specifically naming it. Also can anyone
give me some pointer on how to attach events to them. Regards.


 
Reply With Quote
 
 
 
 
ccallen
Guest
Posts: n/a
 
      04-12-2004
See my reply in "Re: Dynamicly loaded User Control events in a Placeholder"

Search MSDN for EventHandler to get a listing of info & samples.

/*
* #C snippet showing how to create a user control & add an event handler
* CWebUserControl1 has an event called Alerted, the aspx defines a function
called Alerted2.
* Note the use of += when setting the EvnetHandler.
* The WebUserControl's classname "CWebUserControl1" is set in the ascx file
using the ClassName parameter of the @Control directive
* <%@Control language="C#" ClassName="CWebUserControl1"%>
*/

public void Page_Load(Object sender, EventArgs e) {

CWebUserControl1 ctl = new CWebUserControl1();
ctl = (CWebUserControl1) LoadControl ("WebUserControl1.ascx");
ctl.Alerted += new EventHandler(this.onAlerted2);
ph1.Controls.Add (ctl);

return;
}

ccallen

"Chris Kennedy" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> Can anyone tell me how to reference a a control, e.g. a control I have

added
> to the controls collection without specifically naming it. Also can anyone
> give me some pointer on how to attach events to them. Regards.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Affecting a dynamically created drop down from another dynamically created drop down. msimmons ASP .Net 0 07-16-2009 03:17 PM
Managing ViewState of a dynamically created Custom Composite Server Control -(where the original is also dynamically created) dickster ASP .Net Building Controls 0 12-08-2005 09:32 AM
Referencing value of a dynamically created control =?Utf-8?B?TWlrZQ==?= ASP .Net 1 07-13-2004 09:12 PM
Referencing Dynamically Created Controls in PlaceHolder Leona Vo via .NET 247 ASP .Net Web Controls 0 06-11-2004 01:14 AM
Referencing controls on user controls Jim Corey ASP .Net 1 01-26-2004 07:47 PM



Advertisments