Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Event is not firing in custon control.

Event is not firing in custon control.

Scheduled Pinned Locked Moved ASP.NET
comsysadmin
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Imran Khan Pathan
    wrote on last edited by
    #1

    Hey, I have created following code. But button event is not firing. Please look at the code and tell me where I am doing wrong.

    namespace immu.control
    {
    [ToolboxData("<{0}:myControl runat=server>")]
    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");
        }
    }
    

    }

    Thanks. Imrankhan

    please don't forget to vote on the post that helped you.

    I 1 Reply Last reply
    0
    • I Imran Khan Pathan

      Hey, I have created following code. But button event is not firing. Please look at the code and tell me where I am doing wrong.

      namespace immu.control
      {
      [ToolboxData("<{0}:myControl runat=server>")]
      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");
          }
      }
      

      }

      Thanks. Imrankhan

      please don't forget to vote on the post that helped you.

      I Offline
      I Offline
      Imran Khan Pathan
      wrote on last edited by
      #2

      The problem is solved. Thanks.

      please don't forget to vote on the post that helped you.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups