Используйте modalpopupextender в datalist внутри ретранслятора C#
у меня есть один основной ретранслятор, и внутри него у меня есть один datalist, который содержит ImageButton, при нажатии на эту кнопку это изображение должно быть открыто в modelpopup с соответствующим идентификатором.
Что я уже пробовал:
--- aspx----
<asp:DataList ID="dlimgrep" Visible="false" runat="server" OnItemCommand="dlimgrep_ItemCommand" OnSelectedIndexChanged="dlimgrep_SelectedIndexChanged" RepeatDirection="Horizontal" RepeatColumns="2" RepeatLayout="Table"> <ItemTemplate> <asp:Label ID="lbltlphotoid" runat="server" Visible="false" Text='<%#Eval("timelinephoto_id") %>'></asp:Label> <asp:ImageButton runat="server" Style="margin: 0px 5px 5px 0px;" Width="150px" Height="150px" CommandName="imgshowfull" class="img-responsive" ID="imgbtn" alt="user" CommandArgument='<%#Eval("timelinephoto_id") %>' ImageUrl='<%# "~/ImagePage.aspx?tlpostphtoid=" + System.Convert.ToString(Eval("timelinephoto_id")) %>' /> </ItemTemplate> </asp:DataList> <cc1:ModalPopupExtender ID="ModalPopupExtender3" runat="server" TargetControlID="dlimgrep" PopupControlID="Panelshow" BackgroundCssClass="modalBackground" DropShadow="true"> </cc1:ModalPopupExtender> <asp:Panel ID="Panelshow" class="post-container" runat="server" CssClass="modalPopup" align="center" Style="display: none"> <asp:Image runat="server" Style="margin: 0px 5px 5px 0px;" Width="450px" Height="500px" ImageAlign="Left" ID="imgfull" /> <asp:Label ID="Label1" Text="Help Us Understand What's Happening" runat="server"></asp:Label><br> <asp:Label ID="Label5" Text="What's going on?" runat="server"></asp:Label> <br /> <asp:TextBox ID="TextBox2" Visible="false" runat="server" TextMode="MultiLine"></asp:TextBox> <br /> <div class="fileupload fileupload-new" data-provides="fileupload" style="margin-bottom: 10px;"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatLayout="Table" CssClass="radio_gender" RepeatDirection="Vertical"> <asp:ListItem Selected="True" Text="It's annoying or not interesting" Value="0"></asp:ListItem> <asp:ListItem Text="I think it shouldn't be on BanjaraSocial" Value="1"></asp:ListItem> <asp:ListItem Text="It's spam" Value="2"></asp:ListItem> </asp:RadioButtonList> </div> <asp:Button ID="Button1" OnClick="btnContinue_Click" runat="server" Text="Continue" /> <asp:Button ID="Button3" runat="server" Text="Close" /> </asp:Panel>
и
---цезий---
protected void dlimgrep_ItemCommand(object source, DataListCommandEventArgs e) { SqlConnection conn = new SqlConnection(c.connStr); conn.Open(); if (e.CommandName == "imgshowfull") { //Panel pan = e.Item.FindControl("Panelfull") as Panel; //pan.Visible = true; Image img = e.Item.FindControl("imgfull") as Image; int tlid = Convert.ToInt32(e.CommandArgument); SqlCommand cmdimgfull = new SqlCommand("select timeline_photos from tbl_timelinephotos where timelinephoto_id = '" + tlid + "'", conn); SqlDataReader DRimg = cmdimgfull.ExecuteReader(); if (DRimg.Read()) { byte[] bytes = (byte[])(DRimg["timeline_photos"]); base64String = Convert.ToBase64String(bytes, 0, bytes.Length); img.ImageUrl = "data:image/png;base64," + base64String; } DRimg.Close(); } }