我有一個動態字符串來獲取服務器映射路徑,我們稱之爲strPath。 我試圖通過使用<%strPath%>將此字符串的值傳遞給html,但它不起作用。任何幫助將不勝感激。將動態字符串傳遞給來自CodeBehind的HTML
不要介意這裏的字符串是靜態的,一旦我可以成功地顯示圖片,我會讓它動態的。
protected void Page_Load(object sender, EventArgs e)
{
string imagePath = Server.MapPath("../Uploads/" + "10.jpg");
}
<asp:Image runat="server" ImageUrl="<%imagePath%>" />
你在使用你的代碼背後的語言? – AMember
C#,我試圖用這個字符串作爲img src在頁面上打印圖像。 – user1595357
您是否嘗試過'<%= strPath%>'? – robertc