As always, a few minutes after I sent the message I figured it out. I needed
to implement INamingContainer.

I seem to be having a string of obvious answer type of questions this week
:)

Erick

----- Original Message -----
From: "Erick Thompson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, April 17, 2002 5:22 PM
Subject: [DOTNET] ASP custom web control with Button


> How can I use a Button object in my custom control and be able to handle
the
> click event? I feel like I must be missing something obvious here. I can
> render a button directly in HTML, and I can capture that click event, but
I
> need to embed WebControl objects and handle events from them. The code I'm
> using is below. Only Render and CreateChildControls are called, I have
> breakpoints on all other methods that are never hit.
>
> Thanks,
> Erick
>
> public class ButtonTest : System.Web.UI.WebControls.WebControl,
> IPostBackDataHandler, IPostBackEventHandler
>
> {
>
>             Button button;
>
>
>
>             protected override void Render(HtmlTextWriter output)
>
>             {
>
>                         button.RenderControl(output);
>
>             }
>
>
>
>             public bool LoadPostData(String postDataKey,
NameValueCollection
> values) {
>
>
>
>                         return false;
>
>             }
>
>
>
>             public void RaisePostDataChangedEvent() {
>
>             }
>
>
>
>             private void ButtonClick(object sender, EventArgs e) {
>
>
>
>             }
>
>
>
>             protected override void CreateChildControls() {
>
>                         button = new Button();
>
>                         button.ID = "Submitter";
>
>                         button.Text = "Submit";
>
>                         button.Click += new
EventHandler(this.ButtonClick);
>
>                         this.Controls.Add(button);
>
>             }
>
>
>
>             public void RaisePostBackEvent(string eventArgument) {
>
>
>
>             }
>
> }
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to