我試圖從我的web配置文件中檢索一個路徑字符串,並使用它加上文件名來獲取我需要的圖像的url。我認爲它應該是這樣的:來自web.config的ASP字符串連接在img src
<asp:Image ImageUrl ='<%# System.Configuration.ConfigurationManager.AppSettings["AppPath"] + "&Images/headerbk01.jpg"%>' runat ="server" width="983" height="265" />
這給我一個空的字符串的來源。
編輯:
現在使用此:
<asp:Image ImageUrl ='<%=System.Configuration.ConfigurationManager.AppSettings["AppPath"]+"&Images/headerbk01.jpg"%>' runat ="server" width="983" height="265" />
產生以下爲html:
<img style="width: 983px; height: 265px;" src="<=System.Configuration.ConfigurationManager.AppSettings["AppPath"]+"&Images/headerbk01.jpg"%>"/>
你能嘗試的=而不是代碼中的#號?這可能會有所作爲。 –
謝謝,剛剛嘗試過,沒有改變,我的src直到一個空字符串 – collusionbdbh
我試過了字符串temp = System.Configuration.ConfigurationManager.AppSettings [「AppPath」];在頁面後面的代碼中,它正在拾取正確的值 – collusionbdbh