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

S

scotprince

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top