Results 1 to 6 of 6

Thread: [2005] Event handler never called.

Hybrid View

  1. #1

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [2005] Event handler never called.

    No, that's not it, this.getThumbnails must be called every time to create and populate the ImageButtons. The delegate for the event handler will, or should, ensure it is called no matter if new ImageButtons are created.

    Just to make sure I added an IsPostBack check and didn't create the new Imagebuttons, this had no effect, the handler was still not called.

  2. #2

    Thread Starter
    Hyperactive Member GlenW's Avatar
    Join Date
    Nov 2001
    Location
    Gateshead, England
    Posts
    479

    Re: [2005] Event handler never called.

    This does work, what is wrong with the first one?

    Code:
        protected void Page_Load(object sender, System.EventArgs e)
        {
          this.addButton();
        }
    
        private void addButton()
        {
          ImageButton lButton = new ImageButton();
          lButton.ID = "Click";
          lButton.Click += new ImageClickEventHandler(lButton_Click);
          this.pnlMain.Controls.Add(lButton);
        }
    
        void lButton_Click(object sender, ImageClickEventArgs e)
        {
          ImageButton lButton = sender as ImageButton;
          Response.Write(lButton.ID);
        }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width