composite control does not fire event

Discussion in 'ASP .Net Web Controls' started by Patrick, Jul 18, 2005.

  1. Patrick

    Patrick Guest

    Hi

    I have an aspx-page, where I load my custom-control (see below). The problem
    I have is that the event does not fire. I really cant figure out why. Just
    to know, I derive from System.Web.UI.Control, becaues later on I want to add
    some more controls, but first I have to solve this problem.

    Has someone an idea?

    Thanks
    Patrick


    *************** default.aspx.cs
    protected void Page_Load(object sender, EventArgs e)
    {
    Control ctrl = new Mycustomcontrol();
    this.form1.Controls.Add(ctrl);
    }


    *************** Mycustomcontrol.cs
    public class Mycustomcontrol: System.Web.UI.Control
    {
    private Button bt;

    protected override void CreateChildControls()
    {

    bt = new Button();
    bt.Text = "test";
    this.Controls.Add(bt);
    bt.Click += new EventHandler(bt_Click);
    }

    protected void bt_Click(object sender, EventArgs e)
    {
    System.Web.HttpContext.Current.Response.Write("button was clicked");
    }

    }
     
    Patrick, Jul 18, 2005
    #1
    1. Advertising

  2. Patrick

    Steve Walker Guest

    In message <>, Patrick
    <> writes
    >Hi
    >
    >I have an aspx-page, where I load my custom-control (see below). The problem
    >I have is that the event does not fire. I really cant figure out why. Just
    >to know, I derive from System.Web.UI.Control, becaues later on I want to add
    >some more controls, but first I have to solve this problem.


    Add the marker interface INamingContainer to your control.


    --
    Steve Walker
     
    Steve Walker, Jul 18, 2005
    #2
    1. Advertising

  3. Patrick

    Patrick Guest

    Hi Steve

    Thanks, that was the problem :)

    Patrick

    "Steve Walker" <> schrieb im Newsbeitrag
    news:...
    >
    >
    > In message <>, Patrick
    > <> writes
    >>Hi
    >>
    >>I have an aspx-page, where I load my custom-control (see below). The
    >>problem
    >>I have is that the event does not fire. I really cant figure out why. Just
    >>to know, I derive from System.Web.UI.Control, becaues later on I want to
    >>add
    >>some more controls, but first I have to solve this problem.

    >
    > Add the marker interface INamingContainer to your control.
    >
    >
    > --
    > Steve Walker
     
    Patrick, Jul 18, 2005
    #3
  4. Patrick

    Steve Walker Guest

    In message <>, Patrick
    <> writes
    >> In message <>, Patrick
    >> <> writes

    >"Steve Walker" <> schrieb im Newsbeitrag
    >news:...


    >>>I have an aspx-page, where I load my custom-control (see below). The
    >>>problem
    >>>I have is that the event does not fire. I really cant figure out why. Just
    >>>to know, I derive from System.Web.UI.Control, becaues later on I want to
    >>>add
    >>>some more controls, but first I have to solve this problem.


    >> Add the marker interface INamingContainer to your control.


    >Thanks, that was the problem :)


    You're welcome. I write controls all the time, and that one still bites
    me now and then.

    --
    Steve Walker
     
    Steve Walker, Jul 18, 2005
    #4
    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. Replies:
    0
    Views:
    738
  2. C. Ramsey

    Composite Control datagrid event does not fire

    C. Ramsey, Sep 12, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    170
    Teemu Keiski
    Sep 15, 2003
  3. Chad
    Replies:
    0
    Views:
    242
  4. Patrick

    composite control does not fire event

    Patrick, Jul 15, 2005, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    175
    Patrick
    Jul 19, 2005
  5. Joe Abou Jaoude

    How to fire a client event from a composite control

    Joe Abou Jaoude, Jul 3, 2007, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    793
    Sergey Poberezovskiy
    Jul 4, 2007
Loading...

Share This Page