how to get imageurl of Dynamically created Image Button in click event ?
-
Hi sir, I have created dynamic imagebuttons. In that postbackurl was not working. So i wrote addhandler. I want to open selected image in new window. How to call the selected image id or get the imageurl in img_Click event..? Dim tRow5 As New HtmlTableRow() tblParticulars.Rows.Add(tRow5) tCell = New HtmlTableCell() tCell.Align = "Left" tCell.Width = 300 Dim Img As New ImageButton Img.ID = "AdvImg" & cnt Txt1 = Ds1.Tables(0).Rows(i).Item("AdvImg") Img.ImageUrl = "~/Photos/" & Txt1 Img.Height = "70" Img.Width = "60" AddHandler Img.Click, AddressOf Me.Img_Click tCell.Controls.Add(Img) tRow5.Cells.Add(tCell) Private Sub img_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) End Sub
-
Hi sir, I have created dynamic imagebuttons. In that postbackurl was not working. So i wrote addhandler. I want to open selected image in new window. How to call the selected image id or get the imageurl in img_Click event..? Dim tRow5 As New HtmlTableRow() tblParticulars.Rows.Add(tRow5) tCell = New HtmlTableCell() tCell.Align = "Left" tCell.Width = 300 Dim Img As New ImageButton Img.ID = "AdvImg" & cnt Txt1 = Ds1.Tables(0).Rows(i).Item("AdvImg") Img.ImageUrl = "~/Photos/" & Txt1 Img.Height = "70" Img.Width = "60" AddHandler Img.Click, AddressOf Me.Img_Click tCell.Controls.Add(Img) tRow5.Cells.Add(tCell) Private Sub img_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) End Sub
you have to give events like :(in C#) Img.Click += new EventHandler(Imgbtn_Click); This will fire the event: protected void Imgbtn_Click(object sender, EventArgs e) { //your code here }
Padmanabhan
-
you have to give events like :(in C#) Img.Click += new EventHandler(Imgbtn_Click); This will fire the event: protected void Imgbtn_Click(object sender, EventArgs e) { //your code here }
Padmanabhan
Sir, i also did the same thing using foll vb code AddHandler Img.Click, AddressOf Me.Img_Click i want to know how to get imageurl or the path of the image so that i can open it in new window when i click the image button in foll function. protected void Imgbtn_Click(object sender, EventArgs e) { //code }