asp.net - Close Image and Embed code in String Format (ASP) -
my codes in "item template - asp:repeater element"
when try print them in page (aspx) embed video player can not displayed if image displayed already. think happening cause of not closed tags (image , embed tags). how can close elements in stringformat. i'm newbie @ programming , sorry bad english.
here codes:
<%#(string.isnullorempty(eval("image").tostring()) ? "" : string.format("<img class='img-thumbnail' style='margin-top:15px !important; margin-bottom:15px !important; width:300px; margin: 0 auto;' src='http://example.com/image/{0}'" , eval("image").tostring()))%> <%#(string.isnullorempty(eval("embed").tostring()) ? "" : string.format("<iframe style='margin-left: 20px;' width='300' height='169' src='https://www.youtube.com/embed/{0}'" , eval("embed").tostring())) %>
i think re missing > :
src='http://example.com/image/{0}' >"
and here :
src='https://www.youtube.com/embed/{0}'>"
edit
may rewrite code way better maintenance/readability :
<ul> <asp:repeater runat="server" id="repeater1"> <itemtemplate> <li> <asp:image runat="server" visible='<%# eval("image") != null %>' imageurl=<%# "http://example.com/image/" + eval("image") %> /> </li> </itemtemplate> </asp:repeater> </ul>
regards
Comments
Post a Comment