0
希望我在下面做的是自我解釋。但是,response.write不會在td標籤之間寫入img,而是將其寫入Html的頂部。我試圖做到沒有Response.write,但可以解決如何將@ Lnk.FileName插入到img標籤中,任何人都能夠理解我想要做什麼,並推薦MVC的方式?將值插入MVC html標記
@foreach (Games.Models.GameDetail Lnk in Model.oListSpace)
{
<h3>@Lnk.Name</h3>
<table>
<tr>
<td width="250px">
@if(System.IO.File.Exists(Server.MapPath("~") +"\\pictures\\games\\" + Lnk.Filename+".jpg"))
{
Response.Write("<img src=\"/pictures/games/" + @Lnk.Filename + ".jpg\"/>");
}
else
{
//Response.Write((Server.MapPath("~") + "\\pictures\\games\\" + Lnk.Filename + ".jpg") +"<br/>");
}
<a href="/games/review/@Lnk.Filename">@Lnk.Name</a></td>
<td>@Lnk.ShortDesc</td>
</tr>
</table>
}
感謝您提前的任何答案。如果重複的問題,請提供您認爲重複的鏈接。
感謝您的快速反應。 – MiscellaneousUser