![](/img/trans.png)
[英]How to write dynamically merged number of images and store into one single image in application folder asp.net
[英]how to load images dynamically to image tag using asp.net from folder location
我在頁面上有一個圖像標簽,如下所示
<asp:Image ID="imgbadge" runat="server" Height="200px" Width="200px" />
然后根據下拉框上的選擇,我需要將相應的圖像分配給該圖像控件。
我嘗試這樣做
if (Session["BadgeType"].ToString() == "HAPPY BIRTHDAY")
{
imgbadge.ImageUrl = Server.MapPath("images/HappyBirthdayBadge.png");
}
else
{
imgbadge.ImageUrl = Server.MapPath("images/ServiceAnniversary.png");
}
但是我沒有在頁面上顯示圖像。我嘗試在Web上進行檢查,但是他們正在解釋有關using handlers
。 我沒有獲得所需的完整詳細信息。
謝謝,克里希納
嘗試這個:
System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image();
img.ImageUrl = Server.MapPath("images/ServiceAnniversary.png");;
您需要提供圖像的virtual path
而不是physical path
,請嘗試以下操作:
imgbadge.ImageUrl = "~/images/HappyBirthdayBadge.png";
這應該正確顯示您的圖像。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.