簡體   English   中英

如何刪除 <img> 如果沒有從數據庫提交文件路徑,則標記

[英]How to remove an <img> tag if no file path has been submitted from database

我有一個顯示文章的轉發器,可以或不能提交圖片。

它的效果很好,但是當未插入圖片時,仍然會顯示alt文本,但顯然沒有圖片。

<article class="newsPic">
           <img src="<%# Eval("picFilePath") %>" width="100%" alt="News Picture"/>
</article>

如果該字段為空,那么如果沒有文件路徑提交,如何刪除控件?

我已經找到了,但是目前我看不到如何在其周圍包裹<img>標簽?:

<asp:Label ID="MailingAddress" runat="server" 
   Text='<%# Eval("MailingAddress") %>' 
   Visible='<%# !string.IsNullOrEmpty(Eval("MailingAddress") as string) %>'/>

你只是給自己一個答案:)

<img src='<%# Eval("picFilePath") %>' style="width:100%" alt="News Picture"
    runat="server" visible='<%# !string.IsNullOrEmpty(Eval("picFilePath") as string) %>' />

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM