Event from Control embedded in another control not firing on web form.

Discussion in 'ASP .Net' started by scotprince@gmail.com, Mar 10, 2006.

  1. Guest

    Hi,

    I am hoping someone here can help. I have one custom control called
    "MyButton". On another custom control (CC2) I dynamically create a
    table and add the "MyButton" control to a cell or cells depending on
    what happens on the web form. Then I embed CC2 onto a web form and
    everything compiles and runs. I get the custom button(s) generated.
    The problem is that the button click event is not firing on the web
    form. Below is the code on how I am creating the buttons in "MyButton"
    control.

    protected override void CreateChildControls()
    {
    radbtn = new CallbackButton();
    radbtn.Text = "Click Me";
    radbtn.Click += new EventHandler(btn_Click);
    Controls.Add(radbtn);
    base.CreateChildControls ();
    }


    protected override void Render(HtmlTextWriter output)
    {
    base.Render(output);
    }


    private void btn_Click(object sender, EventArgs e)
    {
    radbtn.Text = "I was clicked!";

    }

    }

    Now if I embed "MyControl" straight onto a webform I can get the click
    events. It is when "MyControl" is embedded in another control is when
    I cannot get the event.
    Do I have to have CC2 subscribe to MyButtons click event then send that
    onto the web form?
    Any ideas? Thanks!

    sp
    , Mar 10, 2006
    #1
    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. sanju
    Replies:
    2
    Views:
    3,762
    sanju reddy
    Jun 17, 2004
  2. ~~~ .NET Ed ~~~
    Replies:
    3
    Views:
    15,057
    nizarbabu
    Sep 8, 2008
  3. xamman
    Replies:
    0
    Views:
    264
    xamman
    Jan 5, 2007
  4. COUTIER Eric

    DataGrid embedded in a control: no DeleteCommand event firing

    COUTIER Eric, Dec 14, 2003, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    112
    COUTIER Eric
    Dec 14, 2003
  5. Rob R. Ainscough
    Replies:
    3
    Views:
    309
    Rob R. Ainscough
    Jun 14, 2005
Loading...

Share This Page