blitzkrieg bop Posted November 12, 2003 Posted November 12, 2003 Hi, I had an imagebutton that worked fine (it would run ImageButton1_Click when I clicked add to cart) until I tried using a placeholder instead of asp:imagebutton. Now when I click the "add to cart" image the ImageButton1_Click doesn't fire. The Page_load does. Anything you can tell me that I'm doing wrong? Is there an imagebutton property I'm missing? Thanks. aspx page: <asp:Placeholder id="PlaceHolder1" runat="server"></asp:Placeholder> code behind page: Public Class WebForm2 Inherits System.Web.UI.Page Public dr As System.Data.SqlClient.SqlDataReader Protected WithEvents ImageButton1 As System.Web.UI.WebControls.ImageButton Protected WithEvents ImageButton2 As System.Web.UI.WebControls.ImageButton Protected WithEvents PlaceHolder1 As System.Web.UI.WebControls.PlaceHolder .... Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load .... Dim ImageButton2 As New ImageButton ImageButton2.ImageUrl = "/_images/add_cart.gif" ImageButton2.AlternateText = "Add to Cart" ImageButton2.ID = "ImageButton1" PlaceHolder1.Controls.Add(ImageButton2) End Sub Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click .... End Sub End Class Quote
Moderators Robby Posted November 12, 2003 Moderators Posted November 12, 2003 You need to add a handler for the click event of any control created at runtime Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.