Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图用 C# 设置图像标签的来源,因为模块并不总是在具有相同路径的同一页面上,尽管它不工作。
<img id="3ways" src='"<%= ConfigurationManager.AppSettings["Images08"].ToString() + "/3ways.png"%>"' border="0" style="padding-bottom:2px;">
为什么不使用 runat="server"?例如:
<img id="3ways" runat="server" src="" border="0" style="padding-bottom:2px;">
然后在后端执行此操作:
3ways.Attributes["src"] = ConfigurationManager.AppSettings["Images08"].ToString() + "/3ways.png"
它更清洁,更好地分离关注点。