locked
Image control is not rendering in Repeater control. RRS feed

  • Question

  • User-930371450 posted

    Hi Team,

    Aspx Code:

    <asp:Repeater ID="rptUserMessages" runat="server">
                                                                                                    <HeaderTemplate>
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>
                                                                                                        <table cellspacing="2" cellpadding="2" border="0">
                                                                                                            <tr class="YlwBoldTxt">
                                                                                                                <td align="left" colspan="3" valign="top" class='<%# " imageMessage"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' > 
                                                                                                                    <asp:LinkButton ID="lnkDelete" runat="server" ToolTip="Delete" CausesValidation="false" onclick='<%#DeleteUserMessage(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <img id="imgCopy" src="../Images/RejectedEmail16x16.gif" alt="Delete" style="border:0" width="20px" height="20px" />                                                                                                                                             
                                                                                                                    </asp:LinkButton>
                                                                                                                    </td>
                                                                                                                    <td align="left" colspan="4" class="lnkmessages"> 
                                                                                                                        <span runat="server" id="lnkUserMessage"  class='<%# "userMailMessage "  + " Message"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' 
                                                                                                                        onclick='<%#GetOpenUserMessageURL(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <%# HttpContext.Current.Server.HtmlDecode(DataBinder.Eval(Container.DataItem, "Message").ToString().Trim())%> </span>                                               
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                        </table>
                                                                                                    </ItemTemplate>
                                                                                                    <FooterTemplate>
                                                                                                    </FooterTemplate>
                                                                                                </asp:Repeater>

    DB:

    From DB,"Message" Column is returning below record

    Message

    <a href="https://www.google.com/DepartmentImages/13/files/File.pdf"><img alt="" src="https://www.google.com/DepartmentImages/13/images\/User.JPG" style="float:left; height:60px; width:181px" /></a>

    After Page binding: image is not displaying and displaying like this "<..." in UI.

    Saturday, July 13, 2019 2:44 PM

Answers

  • User-930371450 posted

    Issue is resolved with 

    Here I changes span to div. Now image is displaying.

    <asp:Repeater ID="rptUserMessages" runat="server">
                                                                                                    <HeaderTemplate>
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>
                                                                                                        <table cellspacing="2" cellpadding="2" border="0">
                                                                                                            <tr class="YlwBoldTxt">
                                                                                                                <td align="left" colspan="3" valign="top" class='<%# " imageMessage"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' > 
                                                                                                                    <asp:LinkButton ID="lnkDelete" runat="server" ToolTip="Delete" CausesValidation="false" onclick='<%#DeleteUserMessage(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <img id="imgCopy" src="../Images/RejectedEmail16x16.gif" alt="Delete" style="border:0" width="20px" height="20px" />                                                                                                                                             
                                                                                                                    </asp:LinkButton>
                                                                                                                    </td>
                                                                                                                    <td align="left" colspan="4" class="lnkmessages"> 
                                                                                                                        <div runat="server" id="lnkUserMessage"  class='<%# "userMailMessage "  + " Message"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' 
                                                                                                                        onclick='<%#GetOpenUserMessageURL(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <%# HttpContext.Current.Server.HtmlDecode(DataBinder.Eval(Container.DataItem, "Message").ToString().Trim())%> </div>                                               
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                        </table>
                                                                                                    </ItemTemplate>
                                                                                                    <FooterTemplate>
                                                                                                    </FooterTemplate>
                                                                                                </asp:Repeater>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 6:07 AM

All replies

  • User288213138 posted

    Hi SSK_Nani,

    According to your description, I tried to reproduce your problem, but I can work normally.

    In my database, the type of the "Message" field is varchar(max).

    The is my data: <a><img src="../1.jpg" style="float:left; height:60px; width:181px" /></a>

    The code:

    <div>
                <asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
                    <ItemTemplate>
                        <table border="0">
                            <tr>
                                <td>
                                    <span id="lnkUserMessage" runat="server">
                                        <%# HttpContext.Current.Server.HtmlDecode(DataBinder.Eval(Container.DataItem, "Message").ToString().Trim())%>  
                                    </span>
                                </td>
                            </tr>
                        </table>
                    </ItemTemplate>          
                </asp:Repeater>
                <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CaseTestConnectionString %>" SelectCommand="SELECT [Message] FROM [Test22]"></asp:SqlDataSource>
            </div>
    

    Best regards,

    Sam

    Monday, July 15, 2019 9:02 AM
  • User-930371450 posted

    Issue is resolved with 

    Here I changes span to div. Now image is displaying.

    <asp:Repeater ID="rptUserMessages" runat="server">
                                                                                                    <HeaderTemplate>
                                                                                                    </HeaderTemplate>
                                                                                                    <ItemTemplate>
                                                                                                        <table cellspacing="2" cellpadding="2" border="0">
                                                                                                            <tr class="YlwBoldTxt">
                                                                                                                <td align="left" colspan="3" valign="top" class='<%# " imageMessage"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' > 
                                                                                                                    <asp:LinkButton ID="lnkDelete" runat="server" ToolTip="Delete" CausesValidation="false" onclick='<%#DeleteUserMessage(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <img id="imgCopy" src="../Images/RejectedEmail16x16.gif" alt="Delete" style="border:0" width="20px" height="20px" />                                                                                                                                             
                                                                                                                    </asp:LinkButton>
                                                                                                                    </td>
                                                                                                                    <td align="left" colspan="4" class="lnkmessages"> 
                                                                                                                        <div runat="server" id="lnkUserMessage"  class='<%# "userMailMessage "  + " Message"+ DataBinder.Eval(Container.DataItem, "MailMessageID").ToString() %>' 
                                                                                                                        onclick='<%#GetOpenUserMessageURL(DataBinder.Eval(Container.DataItem, "MailMessageID").ToString(), DataBinder.Eval(Container.DataItem, "UserID").ToString()) %>'>
                                                                                                                    <%# HttpContext.Current.Server.HtmlDecode(DataBinder.Eval(Container.DataItem, "Message").ToString().Trim())%> </div>                                               
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                        </table>
                                                                                                    </ItemTemplate>
                                                                                                    <FooterTemplate>
                                                                                                    </FooterTemplate>
                                                                                                </asp:Repeater>
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2019 6:07 AM