Referencing Dynamically created controls

Discussion in 'ASP .Net Building Controls' started by Chris Kennedy, Apr 12, 2004.

  1. 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.
     
    Chris Kennedy, Apr 12, 2004
    #1
    1. Advertising

  2. Chris Kennedy

    ccallen Guest

    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" <> wrote in message
    news:%23$...
    > 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.
    >
    >
     
    ccallen, Apr 12, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jim Corey

    Referencing controls on user controls

    Jim Corey, Jan 26, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    371
    Hermit Dave
    Jan 26, 2004
  2. =?Utf-8?B?TWlrZQ==?=

    Referencing value of a dynamically created control

    =?Utf-8?B?TWlrZQ==?=, Jul 13, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    410
    Davide Vernole [MVP]
    Jul 13, 2004
  3. 2obvious
    Replies:
    0
    Views:
    345
    2obvious
    Sep 13, 2004
  4. msimmons
    Replies:
    0
    Views:
    544
    msimmons
    Jul 16, 2009
  5. Leona Vo via .NET 247

    Referencing Dynamically Created Controls in PlaceHolder

    Leona Vo via .NET 247, Jun 11, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    133
    Leona Vo via .NET 247
    Jun 11, 2004
Loading...

Share This Page