我的视图是我的视图。这很好用。
... onclick="location.href = '@Url.Action("Plan", "Care", new {Area = "HomeC"})'"><img src="~/Content/images/dash/Care.PNG"
如何使用Html.Raw执行相同的代码? 我试过这个
grid.Column(columnName: "Name", header: "", format: @<text>@(item.ListStatus == 1 ? Html.Raw("<button class='btn btn-default btn-plan' title='Care' onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''>" +
"<img src='/Content/images/dash/Care.PNG' class='img-plan' data-interlocutorid=" + item.UserId + " " + "data-interlocutorname=" + item.Name + " " + ">" +
"</button>") : Html.Raw(""))
</text>),
图像都很好,但链接不起作用。
答案 0 :(得分:0)
将Url.Action(...)周围的单引号更改为双引号。
即改变这一部分:
onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''
到此:
onclick='location.href = " + "\"" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "\"'
这将改变以下的渲染输出:
onclick='location.href = '/Care/Plan?Area=HomeC''
为:
onclick='location.href = "/Care/Plan?Area=HomeC"'
答案 1 :(得分:0)
background-size
这很好用。