在转发器C#内的datalist中使用modalpopupextender [英] Use modalpopupextender in datalist inside repeater C#

查看:47
本文介绍了在转发器C#内的datalist中使用modalpopupextender的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个主转发器,里面有一个包含ImageButton的数据列表,点击该按钮,该图像应该在modelpopup中以相应的ID打开。



我尝试过:



--- aspx ----

< asp:DataList ID =dlimgrepVisible =falserunat =serverOnItemCommand =dlimgrep_ItemCommandOnSelectedIndexChanged =dlimgrep_SelectedIndexChangedRepeatDirection =Horizo​​ntalRepeatColumns =2RepeatLayout =Table> 
< ItemTemplate>
< asp:Label ID =lbltlphotoidrunat =serverVisible =falseText ='<%#Eval(timelinephoto_id)%>'>< / asp:Label>
< asp:ImageButton runat =serverStyle =margin:0px 5px 5px 0px; Width =150pxHeight =150pxCommandName =imgshowfullclass =img-responsiveID =imgbtnalt =userCommandArgument ='<%#Eval(timelinephoto_id)%>'ImageUrl ='<%#〜/ ImagePage.aspx?tlpostphtoid =+ System.Convert.ToString(Eval(timelinephoto_id))%>'/>

< / ItemTemplate>
< / asp:DataList>
< cc1:ModalPopupExtender ID =ModalPopupExtender3runat =serverTargetControlID =dlimgrepPopupControlID =Panelshow
BackgroundCssClass =modalBackgroundDropShadow =true>
< / cc1:ModalPopupExtender>

< asp:Panel ID =Panelshowclass =post-containerrunat =serverCssClass =modalPopupalign =centerStyle =display:none>
< asp:Image runat =serverStyle =margin:0px 5px 5px 0px;宽度=450px高度=500pxImageAlign =左ID =imgfull/>
< asp:Label ID =Label1Text =帮助我们了解发生了什么runat =server>< / asp:Label>< br>

< asp:Label ID =Label5Text =发生了什么事? runat =server>< / asp:标签>

< br />

< asp:TextBox ID =TextBox2Visible =falserunat =serverTextMode =MultiLine>< / asp:TextBox>

< br />
< div class =fileupload fileupload-newdata-provide =fileuploadstyle =margin-bottom:10px;>

< asp:RadioButtonList ID =RadioButtonList1runat =serverRepeatLayout =TableCssClass =radio_genderRepeatDirection =Vertical>
< asp:ListItem Selected =TrueText =令人讨厌或不感兴趣值=0>< / asp:ListItem>
< asp:ListItem Text =我认为它不应该在BanjaraSocial上Value =1>< / asp:ListItem>
< asp:ListItem Text =它是垃圾邮件Value =2>< / asp:ListItem>
< / asp:RadioButtonList>

< / div>
< asp:Button ID =Button1OnClick =btnContinue_Clickrunat =serverText =Continue/> 
< asp:Button ID =Button3runat =serverText =Close/>
< / asp:Panel>







--- cs ---

 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)作为Panel;
//pan.Visible = true;
Image img = e.Item.FindControl(imgfull)as Image;

int tlid = Convert.ToInt32(e.CommandArgument);
SqlCommand cmdimgfull = new SqlCommand(从tbl_timelinephotos中选择timeline_photos,其中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();
}
}

解决方案

 protected void dlimgrep_ItemCommand(object source ,DataListCommandEventArgs e)
{
SqlConnection conn = new SqlConnection(c.connStr);
conn.Open();
if(e.CommandName ==imgshowfull)
{
ModalPopupExtender3.show()
~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~
// Panel pan = e.Item.FindControl(Panelfull)作为Panel;
//pan.Visible = true;
Image img = e.Item.FindControl(imgfull)as Image;

int tlid = Convert.ToInt32(e.CommandArgument);
SqlCommand cmdimgfull = new SqlCommand(tbl_timelinephotos其中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();
}
}


i have one main repeater and inside that i have one datalist which contains ImageButton ,on clicking on that button that image should get open in modelpopup with respective id.

What I have tried:

---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>



and
---cs---

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();
     }
 }

解决方案

protected void dlimgrep_ItemCommand(object source, DataListCommandEventArgs e)
    {
        SqlConnection conn = new SqlConnection(c.connStr);
        conn.Open();
        if (e.CommandName == "imgshowfull")
        {
            ModalPopupExtender3.show()
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            //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(                                                  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();
        }
    }


这篇关于在转发器C#内的datalist中使用modalpopupextender的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆