locked
Event is not firing RRS feed

  • Question

  • User1037547548 posted

    Hey. I use belove code in custom control. But button event is not firing. Look at my code and tell me where I am doing wrong.

    namespace immu.control
    {
        [ToolboxData("<{0}:myControl runat=server></{0}:myControl>")]
        public class docControl : WebControl
        {
    
            public Button btn;
    
            protected override void CreateChildControls()
            {
                Panel pnl = new Panel();
                btn = new Button();
                btn.Text = "Click Me";
                btn.Click += new EventHandler(btn_Click);
                pnl.Controls.Add(btn);
                this.Controls.Add(pnl);
                //base.CreateChildControls();
            }
    
            public void btn_Click(object sender, EventArgs e)
            {
                HttpContext.Current.Response.Redirect("http://google.com");
            }
        }
    }


    Regard

    Friday, December 18, 2009 7:47 AM

Answers

  • User1037547548 posted

    Thanks, I have already solved my problem by implementing INamaningContainer class.

    Regard

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 18, 2009 11:44 PM

All replies

  • User94749686 posted

    hi.

    try to do same in PreInit event.


    thanks.

    Friday, December 18, 2009 9:53 AM
  • User1037547548 posted

    Thanks, I have already solved my problem by implementing INamaningContainer class.

    Regard

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, December 18, 2009 11:44 PM