SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2007
    0 Post(s)
    0 Thread(s)

    How to check the click propert of the imagebutton added dynamically

    Hello all ,

    I am trying to check whether button is clicked or not which is added dynamically with event handler. if take checkbox everything works fine as i could chked its checked property. but when i took image buton insted of checke box it ask me to raise event now i am not getting how to proced.

    below is the code


    Dim i, j, k, t, count As Integer
    Dim flag As Integer = 0
    Dim sum As Integer = 0
    Dim n As Integer
    Dim s, s1 As String
    Dim chk_string As String
    Dim session_pid As cart_provider() = Session("product_id")
    Dim s_pid As cart_provider()
    lbl_msg.Text = ""
    lbl_msg.Visible = False
    n = UBound(session_pid)
    For j = 0 To n
    Dim lbl_hide As Label = CType(Me.FindControl("ucl" & j & ":lbl_id"), Label)
    s = lbl_hide.Text
    Dim btndelete As ImageButton = CType(Me.FindControl("ucl" & j & ":ImgBtnDelete"), ImageButton)
    If btndelete.clicked Then //here want to checke whether button is clicked or not

    If j <= n Then
    chk_string = chk_string & s & ","
    count = count + 1
    End If
    If s_pid Is Nothing Then
    ReDim s_pid(0)
    ReDim Preserve s_pid(UBound(s_pid) + 1)
    End If
    s_pid(UBound(s_pid)) = session_pid(j)

    End If
    Session("product_id") = s_pid

    Catch ex As Exception
    End Try

    please kindly provide me the solution as soon as possible.

    Thanks in advance

  2. #2
    SitePoint Wizard
    Join Date
    Feb 2007
    0 Post(s)
    0 Thread(s)
    In the Page_Load you should install a handler for the btndelete.Clicked event. My VB is a bit rusty so I abstain from offering the exact code. ASP.NET will ensure that this event is fired if the button was indeed clicked.

    That said, why do you need to create dynamic buttons? Look into defining the button in the markup and just manipulate the Visible property instead.


Posting Permissions

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