asp.net - 连接字符串 - MVC Razor

标签 asp.net razor

使用 Razor View 引擎,我只想转换这样的路径:

src="<%=MyImageServer %>image1.jpg"

进入

src="@MyImageServer[PROBLEM_HERE]image1.jpg"

您看到问题了...有什么建议吗?

注意: MyImageServer 是一个带有路径的变量。

最佳答案

用括号括起来:

src="@(MyImageServer)image1.jpg"

但是您可能希望避免在 View 中出现此类标签汤并编写自定义 HTML 帮助器:

@Html.Image("image1.jpg")

它将负责生成正确的图像。

关于asp.net - 连接字符串 - MVC Razor,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9294065/

相关文章:

asp.net - 将免费提供的 Asp.Net 论坛与 MySQL 数据库上的 Asp.net Web 应用程序集成

c# - 复选框列表 Asp.Net C#

c# - ASP.Net 应用程序对回发的加倍控制

c# - 在 Webmatrix 页面 C# 中将字段名称传递给 Razor @helper

c# - 嵌套 for 循环 - RadioButtonFor 不工作

c# - 无法在 MVC 3 中使用 VAR 字符串添加多个 html 类

c# - 在 ASP.NET 的 Web 服务中使用 session 状态

asp.net - 如何在 DB2 中执行 SELECT SUBSTR(COLUMN1, 1, 3), * FROM TABLE1

c# - 如何将细节模型从 Controller 传递到 View

c# - @Html.EditorFor(m => m) MVC 中的 lambda 语法