开发者

How do I use a spark variable in an html helper?

开发者 https://www.devze.com 2022-12-27 18:07 出处:网络
Can I use a spark variable inside an html helper? Say we have <var url=\"Url.Action(“get”)\" />

Can I use a spark variable inside an html helper?

Say we have

<var url="Url.Action(“get”)" />    
!{Html.Image("~/Content/up.png")}

Now if I need to use the url inside Html.Image as an attribute(part of th开发者_JAVA百科e 2nd param) to get

<img src="~/Content/up.png" type="~/engine/get" />

how do I go about doing it?


<var url='Url.Action("get")' />

is converted to

var url = Url.Action("get");

when interpreting view code, so you can use url as C# variable later:

!{Html.Image("~/Content/up.png",url)}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号