piya p

piya p

  • NA
  • 84
  • 46.2k

How to get selected index og button using javascript? And ho

Apr 24 2014 2:16 AM
In my application I am using Image buttons in datalist.
When user will click on any image button index of that button should come.
and according to that index user will display inner data of image.
This is my code:
 <asp:DataList ID="datalist" RepeatDirection="Horizontal"  RepeatColumns="4"   AlternateText=" "  runat="server"  Height="102px" Width="229px" CellSpacing="5"   >
<ItemTemplate >
       <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# Eval("img1") %>'   Height="150" Width="150"  AlternateText=" " OnClick="ImageButton1_Click" CommandName="imgClick"  />
       <br />
   </ItemTemplate>
   </asp:DataList>

And code for button click is:
ImageButton imgbtn = (ImageButton)sender;
            DataListItem item = (DataListItem)imgbtn.NamingContainer;
                        int index = item.ItemIndex;
                        MyDetails details = (MyDetails)listItems[index];
            int id = details.getAlbumid();

           Response.Redirect("Page2.aspx?id1=" + Convert.ToString(id));

Above code working properly when redirecting.
But I need When user click on any image the page 2 should come as popup page. with selected index n all.
How to make next page as popup?
           


        }

Answers (4)