Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...